all repos — homestead @ 05192b0ec50b23414edc1256d8ba7dcad34d8ff8

Code for my website

barkeep: initial commit

Alan Pearce
commit

05192b0ec50b23414edc1256d8ba7dcad34d8ff8

parent

7e847679559d7f5645a961802ea0da314e8c6aa6

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