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