()
| 21 | var clashPath = flag.String("c", "/c", "https://github.com/Dreamacro/clash-dashboard path ") |
| 22 | |
| 23 | func main() { |
| 24 | flag.Parse() |
| 25 | |
| 26 | r := chi.NewRouter() |
| 27 | r.Use(middleware.Logger) |
| 28 | |
| 29 | // Serve YACD static files |
| 30 | yacdRoot, _ := fs.Sub(yacd, "yacd") |
| 31 | yacdHandler := http.StripPrefix(*yacdPath, http.FileServer(http.FS(yacdRoot))) |
| 32 | r.Handle(*yacdPath, http.RedirectHandler(*yacdPath+"/", http.StatusMovedPermanently)) |
| 33 | r.Handle(*yacdPath+"/*", yacdHandler) |
| 34 | |
| 35 | // Serve Clash static files |
| 36 | clashRoot, _ := fs.Sub(clash, "clash") |
| 37 | clashHandler := http.StripPrefix(*clashPath, http.FileServer(http.FS(clashRoot))) |
| 38 | r.Handle(*clashPath, http.RedirectHandler(*clashPath+"/", http.StatusMovedPermanently)) |
| 39 | r.Handle(*clashPath+"/*", clashHandler) |
| 40 | // Redirect root to YACD |
| 41 | r.Get("/", func(w http.ResponseWriter, r *http.Request) { |
| 42 | http.Redirect(w, r, *yacdPath, http.StatusMovedPermanently) |
| 43 | }) |
| 44 | |
| 45 | // Start server |
| 46 | http.ListenAndServe(*addr, r) |
| 47 | } |
nothing calls this directly
no outgoing calls
no test coverage detected