From 2203a437cc7ba0ca087a47d6e99476ba5e09ae71 Mon Sep 17 00:00:00 2001 From: Mitch Riedstra Date: Sat, 21 Nov 2020 22:41:50 -0500 Subject: Touch up some comments --- http/main.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'http') diff --git a/http/main.go b/http/main.go index 1389ae4..e09f610 100644 --- a/http/main.go +++ b/http/main.go @@ -1,5 +1,6 @@ -// A mostly self explanatory package, it handles website specific -// HTTP requests +// The HTTP package handles serving up web pages from the page interface +// This package assumes you'll be changing directory to where the +// Website's static content, templates and includes are located package http import ( @@ -27,8 +28,11 @@ var NewPage func(string) page.Page = func(u string) page.Page { // index is called var ReindexRedirectTo = "/fullIndex" +// Logger can be overridden, errors and access logging are combined. var Logger = log.New(os.Stderr, "", log.LstdFlags) +// GetHandler Returns a gorilla/mux Router which implements the http.Handler +// interface, allowing you to pull this website into your other Go applications func GetHandler() *mux.Router { if NewPage == nil { fmt.Fprintln(os.Stderr, "Warning, global NewPage method is not defined!") @@ -41,6 +45,8 @@ func GetHandler() *mux.Router { return r } +// PageHandler is usually not called directly from external handlers, but the +// option exists if you're building something custom. func PageHandler(w http.ResponseWriter, r *http.Request) { u := r.URL.Path if u == "/" { @@ -81,6 +87,8 @@ func RebuildIndexHandler(w http.ResponseWriter, r *http.Request) { } } +// StaticHandler simply returns a HTTP handler that looks at the current +// directory and exposes `static` via HTTP `/static` func StaticHandler() http.Handler { return http.StripPrefix("/static/", http.FileServer(http.Dir("static"))) } -- cgit v1.2.3