gohttp/admin/admin.go

35 lines
729 B
Go

package admin
import (
"net/http"
"git.pyer.club/kingecg/gohttpd/server"
)
func about(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
w.Write([]byte("About Page"))
}
func setConfig(w http.ResponseWriter, r *http.Request) {
}
var AdminRoutes = []server.Route{
// Admin Routes
{Method: "GET", Path: "/about", Handle: about},
{Method: "Post", Path: "/config", Handle: setConfig},
}
var AdminServerMux *server.RestMux
func init() {
AdminServerMux = server.NewRestMux("/")
// AdminServerMux.routes = make(map[string]map[string]http.HandlerFunc)
for _, route := range AdminRoutes {
AdminServerMux.HandleFunc(route.Method, route.Path, route.Handle)
}
AdminServerMux.Use(server.BasicAuth)
}