gohttp/admin/admin.go

35 lines
629 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
)
type Route struct {
Method string
Path string
Handle http.HandlerFunc
}
func about(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
w.Write([]byte("About Page"))
}
var AdminRoutes = []Route{
// Admin Routes
{"GET", "/about", about},
}
2023-12-07 22:42:27 +08:00
var AdminServerMux *server.RestMux
2023-12-07 00:22:53 +08:00
func init() {
2023-12-07 22:42:27 +08:00
AdminServerMux = server.NewRestMux("/admin")
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
}
}