Fix: add JSON Content-Type for stream api to avoid buffer in swift
This commit is contained in:
parent
ab8181de1b
commit
74593dad19
1 changed files with 10 additions and 2 deletions
|
@ -44,8 +44,8 @@ func newHub(signal chan struct{}) {
|
||||||
|
|
||||||
r.Use(cors.Handler)
|
r.Use(cors.Handler)
|
||||||
|
|
||||||
r.Get("/traffic", traffic)
|
r.With(jsonContentType).Get("/traffic", traffic)
|
||||||
r.Get("/logs", getLogs)
|
r.With(jsonContentType).Get("/logs", getLogs)
|
||||||
r.Mount("/configs", configRouter())
|
r.Mount("/configs", configRouter())
|
||||||
r.Mount("/proxies", proxyRouter())
|
r.Mount("/proxies", proxyRouter())
|
||||||
r.Mount("/rules", ruleRouter())
|
r.Mount("/rules", ruleRouter())
|
||||||
|
@ -56,6 +56,14 @@ func newHub(signal chan struct{}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func jsonContentType(next http.Handler) http.Handler {
|
||||||
|
fn := func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
next.ServeHTTP(w, r)
|
||||||
|
}
|
||||||
|
return http.HandlerFunc(fn)
|
||||||
|
}
|
||||||
|
|
||||||
func traffic(w http.ResponseWriter, r *http.Request) {
|
func traffic(w http.ResponseWriter, r *http.Request) {
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue