Implement initial login functionality

This commit is contained in:
Tom Wiesing 2022-12-05 16:14:54 +01:00
parent a3bd0db78c
commit 3aa79b0d23
No known key found for this signature in database
36 changed files with 908 additions and 70 deletions

View file

@ -28,7 +28,7 @@ func (ei ErrInterceptor) Intercept(w http.ResponseWriter, r *http.Request, err e
res = ei.Fallback
}
res.ServerHTTP(w, r)
res.ServeHTTP(w, r)
return true
}
@ -65,13 +65,13 @@ var (
)
var (
textInterceptor = StatusInterceptor("text/plain", func(code int, text string) ([]byte, error) {
TextInterceptor = StatusInterceptor("text/plain", func(code int, text string) ([]byte, error) {
return []byte(text), nil
})
jsonInterceptor = StatusInterceptor("application/json", func(code int, text string) ([]byte, error) {
JSONInterceptor = StatusInterceptor("application/json", func(code int, text string) ([]byte, error) {
return json.Marshal(map[string]any{"status": text, "code": code})
})
htmlInterceptor = StatusInterceptor("text/html", func(code int, text string) ([]byte, error) {
HTMLInterceptor = StatusInterceptor("text/html", func(code int, text string) ([]byte, error) {
return []byte(`<!DOCTYPE HTML><title>` + text + `</title>` + text), nil
})
)