chore: improved handler and improved login

This commit is contained in:
2023-09-18 13:50:03 +01:00
parent 1fd025e6d6
commit b22d64a568
7 changed files with 270 additions and 50 deletions

24
main.go
View File

@@ -8,19 +8,19 @@ import (
func main() {
fmt.Println("Starting server on :8000!")
handle := Handle{}
handle := NewHandler()
handle.New()
handle.GetHTML("/", AnswerTemplate("index.html", nil))
handle.GetHTML("/login", AnswerTemplate("login.html", nil))
handle.Post("/login", func(mode AnswerType, w http.ResponseWriter, r *http.Request) *Error {
if mode == JSON {
return &Error{code: 404}
}
handle.Get("login", func(mode AnswerType, w http.ResponseWriter, r *http.Request) *Error {
if mode == JSON {
return &Error{
code: 404,
};
}
LoadBasedOnAnswer(mode, w, "login.html", nil)
return nil;
})
w.Header().Set("Location", "/")
w.WriteHeader(http.StatusSeeOther)
return nil
})
handle.Startup()
handle.Startup()
}