sync from project
This commit is contained in:
@ -22,6 +22,26 @@ type ErrorResponse interface {
|
||||
WriteResponse(http.ResponseWriter)
|
||||
}
|
||||
|
||||
func WrapSimpleErrorWithStatus(message string, status int) ErrorResponse {
|
||||
return simpleErrorResponseWithoutBody{
|
||||
message: message,
|
||||
status: status,
|
||||
}
|
||||
}
|
||||
|
||||
type simpleErrorResponseWithoutBody struct {
|
||||
message string
|
||||
status int
|
||||
}
|
||||
|
||||
func (err simpleErrorResponseWithoutBody) Error() string {
|
||||
return err.message
|
||||
}
|
||||
|
||||
func (err simpleErrorResponseWithoutBody) WriteResponse(w http.ResponseWriter) {
|
||||
w.WriteHeader(err.status)
|
||||
}
|
||||
|
||||
func init() {
|
||||
RegisterExtractorThatTakesResponseWriterGeneric[http.ResponseWriter](func(w http.ResponseWriter, r *http.Request) (any, error) {
|
||||
return w, nil
|
||||
|
Reference in New Issue
Block a user