mirror of
https://github.com/yanislav-igonin/micrach
synced 2025-04-19 11:20:33 +03:00
gateway request wip
This commit is contained in:
parent
5fe7b8ed74
commit
6fea2e3331
19
main.go
19
main.go
@ -1,8 +1,12 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"html/template"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
@ -69,6 +73,21 @@ func main() {
|
||||
router.Static("/static", "./static")
|
||||
if Config.App.Gateway.Url != "" {
|
||||
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.POST("/", Controllers.CreateThread)
|
||||
|
Loading…
Reference in New Issue
Block a user