gogmagog/routes/errors.go
Deepak 262321a1e2
All checks were successful
gitea-deepak/gogmagog/pipeline/head This commit looks good
Adds auth route that checks username and password
2021-01-12 12:43:45 -06:00

33 lines
843 B
Go

package routes
import (
"log"
"net/http"
)
func serverError(w http.ResponseWriter, err error) {
code := http.StatusInternalServerError
log.Printf("received error: {%v}", err)
http.Error(w, http.StatusText(code), code)
}
func badRequestError(w http.ResponseWriter, err error) {
code := http.StatusBadRequest
log.Printf("received error: {%v}", err)
http.Error(w, http.StatusText(code), code)
}
func methodNotAllowedHandler(w http.ResponseWriter, r *http.Request) {
code := http.StatusMethodNotAllowed
http.Error(w, http.StatusText(code), code)
}
func notFoundHandler(w http.ResponseWriter, r *http.Request) {
code := http.StatusNotFound
http.Error(w, http.StatusText(code), code)
}
func unauthorizedHandler(w http.ResponseWriter, r *http.Request) {
code := http.StatusUnauthorized
http.Error(w, http.StatusText(code), code)
}