gohttp/admin/admin.go

35 lines
729 B
Go
Raw Normal View History

2023-12-07 00:22:53 +08:00
package admin
import (
"net/http"
2023-12-07 22:42:27 +08:00
"git.pyer.club/kingecg/gohttpd/server"
2023-12-07 00:22:53 +08:00
)
func about(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
w.Write([]byte("About Page"))
}
2023-12-11 18:15:29 +08:00
func setConfig(w http.ResponseWriter, r *http.Request) {
}
2023-12-12 00:42:21 +08:00
var AdminRoutes = []server.Route{
2023-12-07 00:22:53 +08:00
// Admin Routes
2023-12-12 00:42:21 +08:00
{Method: "GET", Path: "/about", Handle: about},
{Method: "Post", Path: "/config", Handle: setConfig},
2023-12-07 00:22:53 +08:00
}
2023-12-07 22:42:27 +08:00
var AdminServerMux *server.RestMux
2023-12-07 00:22:53 +08:00
func init() {
2023-12-08 22:02:36 +08:00
AdminServerMux = server.NewRestMux("/")
2023-12-07 00:22:53 +08:00
// AdminServerMux.routes = make(map[string]map[string]http.HandlerFunc)
for _, route := range AdminRoutes {
2023-12-07 22:42:27 +08:00
AdminServerMux.HandleFunc(route.Method, route.Path, route.Handle)
2023-12-07 00:22:53 +08:00
}
2023-12-11 18:15:29 +08:00
AdminServerMux.Use(server.BasicAuth)
2023-12-07 00:22:53 +08:00
}