From 545ebd7cebd891f6099d3a62f219d49303af0fca Mon Sep 17 00:00:00 2001 From: Alex Scerba Date: Sat, 9 Nov 2024 23:21:53 -0500 Subject: Move to dynamic blog system --- cmd/http/main.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'cmd/http/main.go') diff --git a/cmd/http/main.go b/cmd/http/main.go index a75ccfc..951c02f 100644 --- a/cmd/http/main.go +++ b/cmd/http/main.go @@ -18,7 +18,7 @@ type application struct { infoLog *log.Logger } -func (app *application) httpsRedirect(w http.ResponseWriter, req *http.Request) { +/*func (app *application) httpsRedirect(w http.ResponseWriter, req *http.Request) { // remove/add not default ports from req.Host target := "https://" + req.Host + req.URL.Path if len(req.URL.RawQuery) > 0 { @@ -28,12 +28,12 @@ func (app *application) httpsRedirect(w http.ResponseWriter, req *http.Request) http.Redirect(w, req, target, // see comments below and consider the codes 308, 302, or 301 http.StatusMovedPermanently) -} +}*/ func (app *application) wwwRedirect(h http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if !strings.HasPrefix(r.Host, "www.") { - http.Redirect(w, r, "https://www."+r.Host+r.RequestURI, 302) + http.Redirect(w, r, "https://www."+r.Host+r.RequestURI, http.StatusFound) return } @@ -66,8 +66,10 @@ func main() { mux.HandleFunc("/gallery/", app.page) mux.HandleFunc("/links", app.page) mux.HandleFunc("/links/", app.page) - mux.HandleFunc("/blog", app.page) - mux.HandleFunc("/blog/", app.page) + mux.HandleFunc("/blog", app.blog) + mux.HandleFunc("/blog/", app.blog) + mux.HandleFunc("/archive", app.archive) + mux.HandleFunc("/archive/", app.archive) mux.HandleFunc("/", app.home) if *addr == ":443" { -- cgit v1.2.3