From 5fe7b8ed7457a72c88f84846467dcafbbc7212c5 Mon Sep 17 00:00:00 2001 From: Yanislav Igonin Date: Thu, 10 Feb 2022 13:10:48 +0200 Subject: [PATCH] feat: update config --- config/config.go | 14 ++++++++++---- controllers/gateway_controller.go | 3 ++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/config/config.go b/config/config.go index 1e09ef7..62a0e99 100644 --- a/config/config.go +++ b/config/config.go @@ -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, } } diff --git a/controllers/gateway_controller.go b/controllers/gateway_controller.go index 5d23e1a..1cc7d22 100644 --- a/controllers/gateway_controller.go +++ b/controllers/gateway_controller.go @@ -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{