Restructured services

This commit is contained in:
Sasha Koshka
2023-05-29 17:03:27 -04:00
parent 5e37c4bb8f
commit d716aa9455
5 changed files with 203 additions and 158 deletions

View File

@@ -12,7 +12,7 @@ type Post struct {
}
type Board struct {
service.Service
*service.Service
root string
mux *http.ServeMux
@@ -25,15 +25,11 @@ type Board struct {
func main () {
board := Board { root: "/board/" }
board.mux = http.NewServeMux()
board.Service = service.Service {
&service.HTTP {
Mount: service.M (
"Board",
"A board where you can post things.",
"@", board.root),
Handler: board.mux,
},
}
board.Service = service.NewService (
"Board",
"A board where you can post things.",
service.NewHTTP("@", board.root, board.mux))
handle := func (pattern string, handler func (http.ResponseWriter, *http.Request)) {
board.mux.HandleFunc(pattern, handler)
}