Added JSON ERROR

This commit is contained in:
cdricms
2025-01-15 15:28:14 +01:00
parent ca313299cf
commit 49005d7768
2 changed files with 35 additions and 17 deletions

View File

@@ -32,14 +32,6 @@ 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 {
@@ -91,7 +83,6 @@ func main() {
"/": {handler, nil},
"/users/login": {HandleLogin, nil},
"/users/new": {handlerCreateUser, AuthJWT},
"/error": {er, nil},
})
fmt.Printf("Serving on port %s\n", port)