2 Commits

Author SHA1 Message Date
64551704a3 Use proper methods and fix redirect handler
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2022-03-30 22:08:51 -04:00
d2d8e6ecad I'm an idiot who forgot to flag.Parse()
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2022-03-30 21:44:58 -04:00

14
main.go
View File

@ -50,6 +50,8 @@ var (
) )
func main() { func main() {
flag.Parse()
viper.SetDefault("bind", ":8080") viper.SetDefault("bind", ":8080")
viper.SetConfigName("dlrouter") // name of config file (without extension) viper.SetConfigName("dlrouter") // name of config file (without extension)
@ -112,12 +114,12 @@ func main() {
r.Use(RealIPMiddleware) r.Use(RealIPMiddleware)
r.Use(logger.Logger("router", log.StandardLogger())) r.Use(logger.Logger("router", log.StandardLogger()))
r.HandleFunc("/status", statusHandler) r.Get("/status", statusHandler)
r.HandleFunc("/mirrors", mirrorsHandler) r.Get("/mirrors", mirrorsHandler)
r.HandleFunc("/reload", reloadHandler) r.Post("/reload", reloadHandler)
r.HandleFunc("/dl_map", dlMapHandler) r.Get("/dl_map", dlMapHandler)
r.Handle("/metrics", promhttp.Handler()) r.Get("/metrics", promhttp.Handler().ServeHTTP)
r.HandleFunc("/", redirectHandler) r.HandleFunc("/*", redirectHandler)
go http.ListenAndServe(viper.GetString("bind"), r) go http.ListenAndServe(viper.GetString("bind"), r)