add url of board to request to gateway

This commit is contained in:
Yanislav Igonin 2022-02-26 14:12:21 +02:00
parent a30cf2fbd6
commit 46fd34ebf6
3 changed files with 8 additions and 2 deletions

View File

@ -9,4 +9,5 @@ IS_CAPTCHA_ACTIVE=true
GATEWAY_URL=http://localhost:3001
GATEWAY_API_KEY=example
GATEWAY_BOARD_ID=b
GATEWAY_BOARD_URL=http://localhost:3000
GATEWAY_BOARD_DESCRIPTION=Random

View File

@ -11,6 +11,7 @@ type GatewayConfig struct {
Url string
ApiKey string
BoardId string
BoardUrl string
BoardDescription string
}
@ -59,11 +60,13 @@ func getGatewayConfig() GatewayConfig {
apiKey := os.Getenv("GATEWAY_API_KEY")
boardId := os.Getenv("GATEWAY_BOARD_ID")
description := os.Getenv("GATEWAY_BOARD_DESCRIPTION")
boardUrl := os.Getenv("GATEWAY_BOARD_URL")
return GatewayConfig{
Url: url,
ApiKey: apiKey,
BoardId: boardId,
BoardUrl: boardUrl,
BoardDescription: description,
}
}

View File

@ -13,8 +13,9 @@ import (
// Make http request to gateway to tell the board id and description
func Connect() {
requestBody, _ := json.Marshal(map[string]string{
"id": Config.App.Gateway.BoardId,
"description": Config.App.Gateway.BoardDescription,
"id": Config.App.Gateway.BoardId,
"name": Config.App.Gateway.BoardDescription,
"url": Config.App.Gateway.Url,
})
url := Config.App.Gateway.Url + "/api/boards"
req, err := http.NewRequest("POST", url, bytes.NewBuffer(requestBody))
@ -33,4 +34,5 @@ func Connect() {
if err != nil {
log.Panicln(err)
}
log.Println("gateway - online")
}