Add SetErrorHandler method to DefaultResponseBuilder

This commit is contained in:
some 2024-10-10 15:04:22 -04:00
parent 33f2e8dfdd
commit 69e5bcefe5
Signed by: some
GPG Key ID: 65D0589220B9BFC8

View File

@ -236,6 +236,11 @@ func NewDefaultResponseBuilder() *DefaultResponseBuilder {
return &DefaultResponseBuilder{}
}
func (rsb *DefaultResponseBuilder) SetErrorHandler(errorHandler Error) *DefaultResponseBuilder {
rsb.errorHandler = errorHandler
return rsb
}
func (rsb *DefaultResponseBuilder) SetStatus(code *int) *DefaultResponseBuilder {
rsb.status = code
return rsb
@ -254,6 +259,9 @@ func (rsb *DefaultResponseBuilder) SetBody(parsed *Body, fields body) *DefaultRe
}
func (rsb *DefaultResponseBuilder) SetDefaults() *DefaultResponseBuilder {
if rsb.errorHandler == nil {
rsb.errorHandler = &DefaultErrorHandler{}
}
if rsb.status == nil {
c := http.StatusOK
rsb.status = &c