aboutsummaryrefslogtreecommitdiff
path: root/cmd/server/handlers.go
diff options
context:
space:
mode:
authorMitchell Riedstra <mitch@riedstra.dev>2021-07-18 16:27:24 -0400
committerMitchell Riedstra <mitch@riedstra.dev>2021-07-18 16:27:24 -0400
commitbcf6d391f17a193c81ad6643f8d006de6c6abad8 (patch)
treeb8eaec45b02d79f8d51d6726ffbbe34ce5de2ed7 /cmd/server/handlers.go
parent904e37a88a6a2eab3919f7f2c40bbb2c07544a7c (diff)
downloadgo-website-0.0.13.tar.gz
go-website-0.0.13.tar.xz
Adjust the program a bit, remove clunky "head" templates. Add an example site among other improvementsv0.0.13
Diffstat (limited to 'cmd/server/handlers.go')
-rw-r--r--cmd/server/handlers.go30
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)
-}