mirror of https://github.com/perkeep/perkeep.git
httputil: add ForbiddenError and RequestEntityTooLargeError
Change-Id: Ie013c2b79bd75b3c1ba14f94b334bb009b61c4d3 Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
6f2af62b81
commit
310e0474be
|
@ -30,12 +30,24 @@ func ErrorRouting(conn http.ResponseWriter, req *http.Request) {
|
|||
log.Printf("Internal routing error on %q", req.URL.Path)
|
||||
}
|
||||
|
||||
func BadRequestError(conn http.ResponseWriter, errorMessage string) {
|
||||
func BadRequestError(conn http.ResponseWriter, errorMessage string, args ...interface{}) {
|
||||
conn.WriteHeader(http.StatusBadRequest)
|
||||
log.Printf("Bad request: %s", errorMessage)
|
||||
log.Printf("Bad request: %s", fmt.Sprintf(errorMessage, args...))
|
||||
fmt.Fprintf(conn, "%s\n", errorMessage)
|
||||
}
|
||||
|
||||
func ForbiddenError(conn http.ResponseWriter, errorMessage string, args ...interface{}) {
|
||||
conn.WriteHeader(http.StatusForbidden)
|
||||
log.Printf("Forbidden: %s", fmt.Sprintf(errorMessage, args...))
|
||||
fmt.Fprintf(conn, "<h1>Forbidden</h1>")
|
||||
}
|
||||
|
||||
func RequestEntityTooLargeError(conn http.ResponseWriter, errorMessage string, args ...interface{}) {
|
||||
conn.WriteHeader(http.StatusForbidden)
|
||||
log.Printf("Request entity is too large: %s", fmt.Sprintf(errorMessage, args...))
|
||||
fmt.Fprintf(conn, "<h1>Request entity is too large</h1>")
|
||||
}
|
||||
|
||||
func ServerError(conn http.ResponseWriter, err os.Error) {
|
||||
conn.WriteHeader(http.StatusInternalServerError)
|
||||
fmt.Fprintf(conn, "Server error: %s\n", err)
|
||||
|
|
Loading…
Reference in New Issue