-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
36 lines (30 loc) · 739 Bytes
/
main.go
File metadata and controls
36 lines (30 loc) · 739 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
import (
"fmt"
"log"
"net/http"
envoy "github.com/andref5/engovy/pkg/control-plane"
)
const (
HttpPort = "8001"
EnvoyXdsPort = 18000
)
func main() {
controlPlane := envoy.ControlPlane{}
go controlPlane.Start(EnvoyXdsPort)
http.HandleFunc("/changeRoute", func(w http.ResponseWriter, r *http.Request) {
path := r.FormValue("path")
if len(path) <= 0 {
http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
return
}
err := controlPlane.ChangeRoutePath(path)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
fmt.Fprintf(w, "OK")
})
log.Println("HTTP server startup port " + HttpPort)
http.ListenAndServe(":"+HttpPort, nil)
}