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_URL=http://localhost:3001
GATEWAY_API_KEY=example GATEWAY_API_KEY=example
GATEWAY_BOARD_ID=b GATEWAY_BOARD_ID=b
GATEWAY_BOARD_URL=http://localhost:3000
GATEWAY_BOARD_DESCRIPTION=Random GATEWAY_BOARD_DESCRIPTION=Random

View File

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

View File

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