latest
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing

This commit is contained in:
2023-01-28 19:05:02 -08:00
parent 3f49d528e7
commit 49709ad3d2
18 changed files with 224 additions and 180 deletions

View File

@@ -1,12 +0,0 @@
package handlers
import (
"fmt"
"net/http"
)
func (s *Handlers) HandleLogin() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "hello login")
}
}

View File

@@ -1,17 +1,16 @@
package handlers
import (
"html/template"
"net/http"
"git.eeqj.de/sneak/gohttpserver/templates"
)
func (s *Handlers) HandleIndex() http.HandlerFunc {
indexTemplate := template.Must(template.New("index").Parse(templates.MustString("index.html")))
t := templates.GetParsed()
return func(w http.ResponseWriter, r *http.Request) {
err := indexTemplate.ExecuteTemplate(w, "index", nil)
err := t.ExecuteTemplate(w, "index.html", nil)
if err != nil {
s.log.Error().Err(err).Msg("")
http.Error(w, http.StatusText(500), 500)

View File

@@ -0,0 +1,19 @@
package handlers
import (
"net/http"
"git.eeqj.de/sneak/gohttpserver/templates"
)
func (s *Handlers) HandleLoginGET() http.HandlerFunc {
t := templates.GetParsed()
return func(w http.ResponseWriter, r *http.Request) {
err := t.ExecuteTemplate(w, "login.html", nil)
if err != nil {
s.log.Error().Err(err).Msg("")
http.Error(w, http.StatusText(500), 500)
}
}
}