mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Fixes to recent extension changes. (#568)
* Fixes to recent extension changes. * Fixes issue where gin will continue calling the handler even if next() isn't called. * Updated docs.
This commit is contained in:
@@ -43,6 +43,12 @@ func HandleErrorResponse(ctx context.Context, w http.ResponseWriter, err error)
|
||||
statuscode = http.StatusInternalServerError
|
||||
err = ErrInternalServerError
|
||||
}
|
||||
WriteError(ctx, w, statuscode, err)
|
||||
}
|
||||
|
||||
// WriteError easy way to do standard error response, but can set statuscode and error message easier than HandleErrorResponse
|
||||
func WriteError(ctx context.Context, w http.ResponseWriter, statuscode int, err error) {
|
||||
log := common.Logger(ctx)
|
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
w.WriteHeader(statuscode)
|
||||
err = json.NewEncoder(w).Encode(simpleError(err))
|
||||
|
||||
Reference in New Issue
Block a user