gohttp/admin/admin.go

30 lines
689 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
2023-12-12 21:44:35 +08:00
"git.pyer.club/kingecg/gohttpd/model"
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-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-12 21:44:35 +08:00
AdminServerMux.Use(server.BasicAuth)
AdminServerMux.HandleFunc("GET", "/about", http.HandlerFunc(about))
postConfigRoute := AdminServerMux.HandleFunc("POST", "/config", http.HandlerFunc(setConfig))
postConfigRoute.Add(server.Parse[model.HttpServerConfig])
2023-12-11 18:15:29 +08:00
AdminServerMux.Use(server.BasicAuth)
2023-12-07 00:22:53 +08:00
}