chore: improved handler and improved login
This commit is contained in:
24
main.go
24
main.go
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user