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) } }