Handling properly now ?

This commit is contained in:
cdricms
2025-01-15 15:16:16 +01:00
parent 3ac25f2a83
commit ca313299cf
3 changed files with 85 additions and 13 deletions

View File

@@ -32,6 +32,14 @@ func (dsn *DSN) ToString() string {
return fmt.Sprintf("postgres://%s:%s@%s:%s/%s?sslmode=disable", dsn.User, dsn.Password, dsn.Hostname, dsn.Port, dsn.DBName)
}
func er(w http.ResponseWriter, r *http.Request) {
_ = r
JSONError{
Status: Error,
Message: "Nope",
}.Respond(w, http.StatusUnauthorized)
}
func handlerCreateUser(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {
@@ -83,6 +91,7 @@ func main() {
"/": {handler, nil},
"/users/login": {HandleLogin, nil},
"/users/new": {handlerCreateUser, AuthJWT},
"/error": {er, nil},
})
fmt.Printf("Serving on port %s\n", port)