From 46fd34ebf63c1d5677cbe69e18f50e6c3e664cb9 Mon Sep 17 00:00:00 2001 From: Yanislav Igonin Date: Sat, 26 Feb 2022 14:12:21 +0200 Subject: [PATCH] add url of board to request to gateway --- .env.example | 1 + config/config.go | 3 +++ gateway/connect.go | 6 ++++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index 25a1e53..ba539bd 100644 --- a/.env.example +++ b/.env.example @@ -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 \ No newline at end of file diff --git a/config/config.go b/config/config.go index 62a0e99..45fcb40 100644 --- a/config/config.go +++ b/config/config.go @@ -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, } } diff --git a/gateway/connect.go b/gateway/connect.go index 7ecca65..8b0611e 100644 --- a/gateway/connect.go +++ b/gateway/connect.go @@ -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") }