41 lines
756 B
Go
41 lines
756 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"))
|
|
|
|
}
|
|
|
|
func setConfig(w http.ResponseWriter, r *http.Request) {
|
|
|
|
}
|
|
|
|
var AdminRoutes = []Route{
|
|
// Admin Routes
|
|
{"GET", "/about", about},
|
|
{"Post", "/config", 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)
|
|
}
|