feat: add auth header for gateway request

This commit is contained in:
Yanislav Igonin 2022-02-10 19:35:20 +02:00
parent 6fea2e3331
commit 124c524e78
2 changed files with 10 additions and 3 deletions

View File

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

11
main.go
View File

@ -78,8 +78,15 @@ func main() {
"id": Config.App.Gateway.BoardId,
"description": Config.App.Gateway.BoardDescription,
})
requestBodyBuffer := bytes.NewBuffer(requestBody)
resp, err := http.Post(Config.App.Gateway.Url+"/boards", "application/json", requestBodyBuffer)
url := Config.App.Gateway.Url + "/boards"
req, err := http.NewRequest("POST", url, bytes.NewBuffer(requestBody))
if err != nil {
log.Panicln(err)
}
req.Header.Set("Authorization", Config.App.Gateway.ApiKey)
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
log.Panicln(err)
}