mirror of
https://github.com/yanislav-igonin/micrach
synced 2025-04-20 03:40: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
|
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)
|
||||||
|
Loading…
Reference in New Issue
Block a user