barkeep: initial commit
1 file changed, 34 insertions(+), 0 deletions(-)
changed files
A internal/publisher/mux.go
@@ -0,0 +1,34 @@ +package publisher + +import ( + "net/http" + + ihttp "go.alanpearce.eu/homestead/internal/http" + pubtpl "go.alanpearce.eu/homestead/internal/publisher/templates" + "go.alanpearce.eu/homestead/templates" +) + +func (app *App) Index(w http.ResponseWriter, _ *http.Request) *ihttp.Error { + err := pubtpl.IndexPage(app.siteSettings, templates.PageSettings{ + Title: "Home", + }).Render(w) + + if err != nil { + return &ihttp.Error{ + Code: http.StatusInternalServerError, + Message: "Failed to render index page", + } + } + + return nil +} + +func (app *App) Style(w http.ResponseWriter, _ *http.Request) *ihttp.Error { + w.Header().Set("Content-Type", "text/css") + _, err := w.Write([]byte(templates.CSS)) + if err != nil { + return &ihttp.Error{Code: http.StatusInternalServerError, Message: err.Error()} + } + + return nil +}