Co-authored-by: stcb <21@stcb.cc> Reviewed-on: icing/G-EIP-700-TLS-7-1-eip-stephane.corbiere#4 Co-authored-by: ange <ange@yw5n.com> Co-committed-by: ange <ange@yw5n.com>
30 lines
616 B
Go
30 lines
616 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"path/filepath"
|
|
)
|
|
|
|
func index(w http.ResponseWriter, r *http.Request) {
|
|
html(w, r.WithContext(
|
|
context.WithValue(r.Context(), URLParam{}, []string{"index"}),
|
|
))
|
|
}
|
|
|
|
func static(w http.ResponseWriter, r *http.Request) {
|
|
http.ServeFile(w, r, r.URL.Path)
|
|
}
|
|
|
|
func css(w http.ResponseWriter, r *http.Request) {
|
|
http.ServeFile(w, r, filepath.Join("css", getParam(r, 0)))
|
|
}
|
|
|
|
func html(w http.ResponseWriter, r *http.Request) {
|
|
if t, found := TMPL[getParam(r, 0)]; found {
|
|
w.Write(t)
|
|
} else {
|
|
http.NotFound(w, r)
|
|
}
|
|
}
|