Noah Petherbridge
2a8a1df6ab
* Initial codebase (lot of work!) * Uses vanilla Go net/http and implements by hand: session cookies backed by Redis; log in/out; CSRF protection; email verification flow; initial database models (User table)
26 lines
575 B
Go
26 lines
575 B
Go
package index
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"git.kirsle.net/apps/gosocial/pkg/log"
|
|
"git.kirsle.net/apps/gosocial/pkg/templates"
|
|
)
|
|
|
|
// Create the controller.
|
|
func Create() http.HandlerFunc {
|
|
tmpl := templates.Must("index.html")
|
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
if r.URL.Path != "/" || r.Method != http.MethodGet {
|
|
log.Error("404 Not Found: %s", r.URL.Path)
|
|
templates.NotFoundPage(w, r)
|
|
return
|
|
}
|
|
|
|
if err := tmpl.Execute(w, r, nil); err != nil {
|
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
return
|
|
}
|
|
})
|
|
}
|