aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitch Riedstra <mitch@riedstra.us>2020-11-21 22:41:50 -0500
committerMitch Riedstra <mitch@riedstra.us>2020-11-21 22:41:50 -0500
commit2203a437cc7ba0ca087a47d6e99476ba5e09ae71 (patch)
treebcc6644c89c005965b8be637b30491ae90e67ec6
parent4006a4d35d807b5360bc4fe5e1b21624e5d5843e (diff)
downloadgo-website-2203a437cc7ba0ca087a47d6e99476ba5e09ae71.tar.gz
go-website-2203a437cc7ba0ca087a47d6e99476ba5e09ae71.tar.xz
Touch up some comments
-rw-r--r--http/main.go12
-rw-r--r--page/main.go2
2 files changed, 12 insertions, 2 deletions
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")))
}
diff --git a/page/main.go b/page/main.go
index 18445d4..ebcf33d 100644
--- a/page/main.go
+++ b/page/main.go
@@ -1,3 +1,5 @@
+// The only purpose of this package is to define the Page interface
+// that is used by the `http` package
package page
import (