sync from project

This commit is contained in:
2025-06-18 10:12:19 +08:00
parent 61ffeeb3b8
commit fb579e8689
20 changed files with 1332 additions and 103 deletions

View File

@ -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