diff --git a/internal/site/templates.go b/internal/site/templates.go index 10ca0cd..e5b96ad 100644 --- a/internal/site/templates.go +++ b/internal/site/templates.go @@ -1,9 +1,11 @@ package site import ( + "errors" "fmt" "net/http" "net/url" + "os" "path" "path/filepath" "strings" @@ -51,6 +53,14 @@ func (s *Server) serveTemplates(w http.ResponseWriter, r *http.Request) { acct, ) if err != nil { + // TODO: handle 401 + + // TODO: handle 403 + + // TODO: handle 404 + if isFileNotFoundError(err) { + } + // TODO: handle 'not found' as a 404? fmt.Println("[ERROR]: failed to load or parse layout template:", err) http.Redirect(w, r, "/", http.StatusTemporaryRedirect) @@ -60,6 +70,13 @@ func (s *Server) serveTemplates(w http.ResponseWriter, r *http.Request) { w.Write(b) } +func isFileNotFoundError(err error) bool { + var pe *os.PathError + isPathErr := errors.As(err, &pe) + + return isPathErr && pe.Err != nil && pe.Err.Error() == "no such file or directory" +} + // TODO: clean this up... // TODO: somehow tell what the path params are and pass them up. // - then consider pushing this functionality into the template library. diff --git a/internal/site/templates/component_bodies/nav_bar.html.tmpl b/internal/site/templates/component_bodies/nav_bar.html.tmpl index bcbf639..4afcfaf 100644 --- a/internal/site/templates/component_bodies/nav_bar.html.tmpl +++ b/internal/site/templates/component_bodies/nav_bar.html.tmpl @@ -1,3 +1,5 @@ +{{/* TODO: delete, once not needed */}} + {{/* "dot" . */}}