yw5ncom/src/views.go
ange e9fc659a5a
All checks were successful
/ deploy (push) Successful in 46s
feat: html static templates
2024-12-14 08:34:47 +00:00

27 lines
498 B
Go

package main
import (
"net/http"
)
func index(w http.ResponseWriter, r *http.Request) {
r.URL.Path = "/contact"
html(w, r)
}
func style(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "html/style.css")
}
func static(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, r.URL.Path)
}
func html(w http.ResponseWriter, r *http.Request) {
if t, found := TMPL[r.URL.Path]; found {
w.Write(t)
} else {
http.NotFound(w, r)
}
}