Fix: allow access to external-ui without authentication (#75)

This commit is contained in:
gVisor bot 2018-12-21 17:48:29 +08:00
parent a3fee826f1
commit 3017aee776

View file

@ -47,6 +47,7 @@ func Start(addr string, secret string) {
MaxAge: 300,
})
r.Group(func(r chi.Router) {
r.Use(cors.Handler, authentication)
r.With(jsonContentType).Get("/traffic", traffic)
@ -54,13 +55,16 @@ func Start(addr string, secret string) {
r.Mount("/configs", configRouter())
r.Mount("/proxies", proxyRouter())
r.Mount("/rules", ruleRouter())
})
if uiPath != "" {
r.Group(func(r chi.Router) {
fs := http.StripPrefix("/ui", http.FileServer(http.Dir(uiPath)))
r.Get("/ui", http.RedirectHandler("/ui/", 301).ServeHTTP)
r.Get("/ui/*", func(w http.ResponseWriter, r *http.Request) {
fs.ServeHTTP(w, r)
})
})
}
log.Infoln("RESTful API listening at: %s", addr)