feat: update config

This commit is contained in:
Yanislav Igonin 2022-02-10 13:10:48 +02:00
parent e1eb14c19e
commit 5fe7b8ed74
2 changed files with 12 additions and 5 deletions

View File

@ -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,
}
}

View File

@ -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{