loading all templates automatically
This commit is contained in:
parent
9f858d50ae
commit
f7498f4ef1
13 changed files with 128 additions and 105 deletions
22
controller.go
Normal file
22
controller.go
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"io/fs"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type controller struct {
|
||||
tmpl map[string]*template.Template
|
||||
http.Handler
|
||||
}
|
||||
|
||||
func (c *controller) LoadRouter(pub fs.FS) {
|
||||
serveMux := http.NewServeMux()
|
||||
|
||||
serveMux.Handle("GET /", http.FileServerFS(unwrap(fs.Sub(pub, "public"))))
|
||||
serveMux.HandleFunc("POST /order/new", c.postNewOrder)
|
||||
serveMux.HandleFunc("GET /cake/options", c.cakeOptions)
|
||||
|
||||
c.Handler = serveMux
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue