micrach/gateway/connect.go
Yanislav Igonin db8a46cdf1
build: modernize Wave 1 baseline (#16)
* chore: add agents md

* docs: expand repository and setup guides

* docs: plan project modernization

* docs: add Wave 1 implementation plan

* test: characterize legacy behavior

* build: update Go and Fiber v2

* fix(gateway): preserve duplicate auth behavior

* refactor(db): migrate to pgx v5

* refactor: replace deprecated I/O APIs

* build: add local PostgreSQL compose

* build: add multi-stage image

* ci: replace legacy deployment workflow

* fix(deps): update vulnerable Go modules

* docs: document modern development workflow
2026-07-16 16:08:54 +09:00

41 lines
940 B
Go

package gateway
import (
"bytes"
"encoding/json"
"io"
"log"
"net/http"
Config "micrach/config"
)
// 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,
"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))
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)
}
defer resp.Body.Close()
//We Read the response body on the line below.
body, err := io.ReadAll(resp.Body)
if err != nil {
log.Panicln(err)
}
log.Println(string(body))
log.Println("gateway - online")
}