set ingress gateway endpoint

This commit is contained in:
afeiszli 2021-05-25 18:05:14 -04:00
parent 3996d48380
commit 85af4dd85f
3 changed files with 9 additions and 3 deletions

View file

@ -313,8 +313,14 @@ func createExtClient(w http.ResponseWriter, r *http.Request) {
var extclient models.ExtClient
extclient.Network = networkName
extclient.IngressGatewayID = macaddress
//get extclient from body of request
err := json.NewDecoder(r.Body).Decode(&extclient)
node, err := functions.GetNodeByMacAddress(networkName, macaddress)
if err != nil {
returnErrorResponse(w, r, formatError(err, "internal"))
return
}
extclient.IngressGatewayEndpoint = node.Endpoint + ":" + strconv.FormatInt(int64(node.ListenPort), 10)
err = json.NewDecoder(r.Body).Decode(&extclient)
if err != nil && !errors.Is(err, io.EOF) {
returnErrorResponse(w, r, formatError(err, "internal"))
return

BIN
models/.extclient.go.swp Normal file

Binary file not shown.

View file

@ -41,5 +41,5 @@ type ExtClient struct {
Address string `json:"address" bson:"address"`
LastModified int64 `json:"lastmodified" bson:"lastmodified"`
IngressGatewayID string `json:"ingressgatewayid" bson:"ingressgatewayid"`
IngressGatewayEnpoint string `json:"ingressgatewayendpoint" bson:"ingressgatewayendpoint"`
IngressGatewayEndpoint string `json:"ingressgatewayendpoint" bson:"ingressgatewayendpoint"`
}