diff options
Diffstat (limited to 'cmd/server/handlers.go')
| -rw-r--r-- | cmd/server/handlers.go | 30 |
1 files changed, 7 insertions, 23 deletions
diff --git a/cmd/server/handlers.go b/cmd/server/handlers.go index 5ea89cd..cb63774 100644 --- a/cmd/server/handlers.go +++ b/cmd/server/handlers.go @@ -9,20 +9,13 @@ import ( "riedstra.dev/mitch/go-website/page" ) -var FeedPrefixDefault = ".feeds" - -type App struct { - ReIndexPath string - StaticDirectory string - - // Related to the Atom feed - Title string - Description string // aka, "subtitle" - Author Author - SiteURL string - FeedId string - Updated page.PageTime - FeedPrefix string +func (a *App) ServeHTTP(w http.ResponseWriter, r *http.Request) { + rtr := mux.NewRouter() + rtr.HandleFunc(a.ReIndexPath, a.RebuildIndexHandler) + rtr.PathPrefix("/static/").Handler(a.StaticHandler()) + rtr.PathPrefix(fmt.Sprintf("/%s/{tag}", a.FeedPrefix)).HandlerFunc(a.FeedHandler) + rtr.PathPrefix("/").HandlerFunc(a.PageHandler) + rtr.ServeHTTP(w, r) } func (a *App) PageHandler(w http.ResponseWriter, r *http.Request) { @@ -55,12 +48,3 @@ func (a *App) RebuildIndexHandler(w http.ResponseWriter, r *http.Request) { func (a *App) StaticHandler() http.Handler { return http.StripPrefix("/static/", http.FileServer(http.Dir(a.StaticDirectory))) } - -func (a *App) ServeHTTP(w http.ResponseWriter, r *http.Request) { - rtr := mux.NewRouter() - rtr.HandleFunc(a.ReIndexPath, a.RebuildIndexHandler) - rtr.PathPrefix("/static/").Handler(a.StaticHandler()) - rtr.PathPrefix(fmt.Sprintf("/%s/{tag}", a.FeedPrefix)).HandlerFunc(a.FeedHandler) - rtr.PathPrefix("/").HandlerFunc(a.PageHandler) - rtr.ServeHTTP(w, r) -} |
