Handling properly now ?
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user