gohttp/admin/admin.go

35 lines
624 B
Go

package admin
import (
"net/http"
"git.pyer.club/kingecg/gohttpd/server"
)
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},
}
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)
}
}