agent-ui rest client generation; initial version endpoint call (#221)

This commit is contained in:
Michael Quigley
2024-10-02 11:11:30 -04:00
parent f7746bbca2
commit 433290d74d
50 changed files with 3712 additions and 12 deletions

View File

@ -99,7 +99,7 @@ func (a *Agent) gateway() {
logrus.Fatalf("unable to register gateway: %v", err)
}
if err := http.ListenAndServe(":8888", mux); err != nil {
if err := http.ListenAndServe(":8888", cors(mux)); err != nil {
logrus.Error(err)
}
}
@ -177,3 +177,15 @@ type agentGrpcImpl struct {
agentGrpc.UnimplementedAgentServer
agent *Agent
}
func cors(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Access-Control-Allow-Origin", r.Header.Get("Origin"))
w.Header().Set("Access-Control-Allow-Methods", "GET, POST, PATCH, DELETE")
w.Header().Set("Access-Control-Allow-Headers", "Accept, Content-Type, Content-Length, Accept-Encoding, Authorization, ResponseType, User-Agent")
if r.Method == "OPTIONS" {
return
}
h.ServeHTTP(w, r)
})
}