gateway request wip

This commit is contained in:
Yanislav Igonin 2022-02-10 13:10:57 +02:00
parent 5fe7b8ed74
commit 6fea2e3331

19
main.go
View File

@ -1,8 +1,12 @@
package main package main
import ( import (
"bytes"
"encoding/json"
"html/template" "html/template"
"io/ioutil"
"log" "log"
"net/http"
"strconv" "strconv"
"time" "time"
@ -69,6 +73,21 @@ func main() {
router.Static("/static", "./static") router.Static("/static", "./static")
if Config.App.Gateway.Url != "" { if Config.App.Gateway.Url != "" {
router.GET("/ping", Controllers.Ping) router.GET("/ping", Controllers.Ping)
// make http request to gateway to tell the board id and description
requestBody, _ := json.Marshal(map[string]string{
"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)
if err != nil {
log.Panicln(err)
}
//We Read the response body on the line below.
_, err = ioutil.ReadAll(resp.Body)
if err != nil {
log.Panicln(err)
}
} }
router.GET("/", Controllers.GetThreads) router.GET("/", Controllers.GetThreads)
router.POST("/", Controllers.CreateThread) router.POST("/", Controllers.CreateThread)