Login Flow
In this commit I added: More pages like history, personal data and editor with dummy content A HTMX login flow The login flow is mostly backend, I think there's nothing on the frontend made to support it. Pretty neat if I say so myself
This commit is contained in:
+41
-2
@@ -10,7 +10,7 @@ func checkMethod(method string, r *http.Request) bool {
|
||||
return r.Method == method
|
||||
}
|
||||
|
||||
func Server() {
|
||||
func Serve() {
|
||||
// GET calls
|
||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
if !checkMethod(http.MethodGet, r) {
|
||||
@@ -18,7 +18,17 @@ func Server() {
|
||||
return
|
||||
}
|
||||
|
||||
controllers.EditorPage(w, r)
|
||||
http.Redirect(w, r, "/login", http.StatusPermanentRedirect)
|
||||
// controllers.Editor(w, r)
|
||||
})
|
||||
|
||||
http.HandleFunc("/login", func(w http.ResponseWriter, r *http.Request) {
|
||||
if !checkMethod(http.MethodGet, r) {
|
||||
w.WriteHeader(http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
|
||||
controllers.Editor(w, r)
|
||||
})
|
||||
|
||||
// POST calls
|
||||
@@ -40,6 +50,35 @@ func Server() {
|
||||
controllers.Authenticate(w, r)
|
||||
})
|
||||
|
||||
// Pages
|
||||
// On default add to a page on invalid methods or something like that
|
||||
http.HandleFunc("/history", func(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.Method {
|
||||
case http.MethodPost:
|
||||
controllers.HistoryPOST(w, r)
|
||||
case http.MethodGet:
|
||||
controllers.History(w, r)
|
||||
}
|
||||
})
|
||||
|
||||
http.HandleFunc("/editor", func(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.Method {
|
||||
case http.MethodPost:
|
||||
controllers.EditorPOST(w, r)
|
||||
case http.MethodGet:
|
||||
controllers.Editor(w, r)
|
||||
}
|
||||
})
|
||||
|
||||
http.HandleFunc("/personalData", func(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.Method {
|
||||
case http.MethodPost:
|
||||
controllers.PersonalDataPOST(w, r)
|
||||
case http.MethodGet:
|
||||
controllers.PersonalData(w, r)
|
||||
}
|
||||
})
|
||||
|
||||
// Serve the CSS and JS files, we might have to change this
|
||||
http.Handle("/assets/", http.StripPrefix("/assets/", http.FileServer(http.Dir("assets"))))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user