mirror of
https://github.com/yanislav-igonin/micrach
synced 2025-04-18 19:00:33 +03:00
feat: update config
This commit is contained in:
parent
e1eb14c19e
commit
5fe7b8ed74
@ -8,8 +8,10 @@ import (
|
||||
)
|
||||
|
||||
type GatewayConfig struct {
|
||||
Url string
|
||||
ApiKey string
|
||||
Url string
|
||||
ApiKey string
|
||||
BoardId string
|
||||
BoardDescription string
|
||||
}
|
||||
|
||||
type AppConfig struct {
|
||||
@ -55,10 +57,14 @@ func getValueOrDefaultString(value string, defaultValue string) string {
|
||||
func getGatewayConfig() GatewayConfig {
|
||||
url := os.Getenv("GATEWAY_URL")
|
||||
apiKey := os.Getenv("GATEWAY_API_KEY")
|
||||
boardId := os.Getenv("GATEWAY_BOARD_ID")
|
||||
description := os.Getenv("GATEWAY_BOARD_DESCRIPTION")
|
||||
|
||||
return GatewayConfig{
|
||||
Url: url,
|
||||
ApiKey: apiKey,
|
||||
Url: url,
|
||||
ApiKey: apiKey,
|
||||
BoardId: boardId,
|
||||
BoardDescription: description,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package controllers
|
||||
|
||||
import (
|
||||
Config "micrach/config"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@ -9,7 +10,7 @@ import (
|
||||
func Ping(c *gin.Context) {
|
||||
headerKey := c.Request.Header.Get("Authorization")
|
||||
if Config.App.Gateway.ApiKey != headerKey {
|
||||
c.AbortWithStatusJSON(401, gin.H{"error": "Unauthorized"})
|
||||
c.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{"error": "Unauthorized"})
|
||||
return
|
||||
}
|
||||
c.JSON(200, gin.H{
|
||||
|
Loading…
Reference in New Issue
Block a user