mirror of
https://github.com/openziti/zrok.git
synced 2025-08-14 18:18:30 +02:00
agent-ui rest client generation; initial version endpoint call (#221)
This commit is contained in:
@ -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)
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user