#73 change authorization
This commit is contained in:
@@ -1,20 +1,25 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"me-fit/templates"
|
||||
"database/sql"
|
||||
"me-fit/template"
|
||||
"net/http"
|
||||
|
||||
"github.com/a-h/templ"
|
||||
)
|
||||
|
||||
func HandleIndexAnd404(w http.ResponseWriter, r *http.Request) {
|
||||
var comp templ.Component = nil
|
||||
if r.URL.Path != "/" {
|
||||
comp = templates.Layout(templates.NotFound())
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
} else {
|
||||
comp = templates.Layout(templates.Index())
|
||||
}
|
||||
func HandleIndexAnd404(db *sql.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var comp templ.Component = nil
|
||||
user_comp := UserInfoComp(verifySessionAndReturnUser(db, r))
|
||||
|
||||
comp.Render(r.Context(), w)
|
||||
if r.URL.Path != "/" {
|
||||
comp = template.Layout(template.NotFound(), user_comp)
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
} else {
|
||||
comp = template.Layout(template.Index(), user_comp)
|
||||
}
|
||||
|
||||
comp.Render(r.Context(), w)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user