mirror of
https://github.com/coder/coder.git
synced 2025-07-06 15:41:45 +00:00
feat: add panic recovery middleware (#3687)
This commit is contained in:
@ -59,6 +59,18 @@ func Forbidden(rw http.ResponseWriter) {
|
||||
})
|
||||
}
|
||||
|
||||
func InternalServerError(rw http.ResponseWriter, err error) {
|
||||
var details string
|
||||
if err != nil {
|
||||
details = err.Error()
|
||||
}
|
||||
|
||||
Write(rw, http.StatusInternalServerError, codersdk.Response{
|
||||
Message: "An internal server error occurred.",
|
||||
Detail: details,
|
||||
})
|
||||
}
|
||||
|
||||
// Write outputs a standardized format to an HTTP response body.
|
||||
func Write(rw http.ResponseWriter, status int, response interface{}) {
|
||||
buf := &bytes.Buffer{}
|
||||
|
Reference in New Issue
Block a user