package web import ( "net/http" "github.com/Jaculabilis/intake/core" "github.com/Jaculabilis/intake/web/html" ) func (env *Env) getRoot(writer http.ResponseWriter, req *http.Request) { if req.URL.Path != "/" { http.NotFound(writer, req) return } names, err := core.GetSources(env.db) if err != nil { writer.Write([]byte(err.Error())) } var sources []html.SourceData for _, name := range names { sources = append(sources, html.SourceData{Name: name}) } data := html.HomeData{ Sources: sources, } html.Home(writer, data) } func (env *Env) getStyle(writer http.ResponseWriter, req *http.Request) { writer.Header()["Cache-Control"] = []string{"public, max-age=86400"} writer.Header()["Content-Type"] = []string{"text/css; charset=utf-8"} writer.Write(html.Stylesheet) } func (env *Env) getScript(writer http.ResponseWriter, req *http.Request) { writer.Header()["Cache-Control"] = []string{"public, max-age=86400"} writer.Header()["Content-Type"] = []string{"application/javascript; charset=utf-8"} writer.Write(html.Htmx) }