Skip to content

Commit 17a8233

Browse files
committed
http serializer
1 parent a3321dd commit 17a8233

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

evo.context.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,18 @@ func (r *Request) WriteResponse(resp ...any) {
159159
r.Write(v.Data)
160160
return
161161
}
162+
if v, ok := instance.(outcome.HTTPSerializer); ok {
163+
response := v.GetResponse()
164+
r.WriteResponse(response)
165+
return
166+
}
167+
if v, ok := instance.(*outcome.HTTPSerializer); ok {
168+
if v != nil {
169+
response := (*v).GetResponse()
170+
r.WriteResponse(response)
171+
return
172+
}
173+
}
162174
if v, ok := instance.(outcome.Response); ok {
163175

164176
if v.StatusCode > 0 {

lib/outcome/outcome.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ import (
1010
"github.com/gofiber/fiber/v2"
1111
)
1212

13+
type HTTPSerializer interface {
14+
GetResponse() Response
15+
}
16+
1317
type Response struct {
1418
ContentType string
1519
Data any

0 commit comments

Comments
 (0)