diff --git a/evo.context.go b/evo.context.go index 84e4fc9..b0d184f 100644 --- a/evo.context.go +++ b/evo.context.go @@ -159,6 +159,18 @@ func (r *Request) WriteResponse(resp ...any) { r.Write(v.Data) return } + if v, ok := instance.(outcome.HTTPSerializer); ok { + response := v.GetResponse() + r.WriteResponse(response) + return + } + if v, ok := instance.(*outcome.HTTPSerializer); ok { + if v != nil { + response := (*v).GetResponse() + r.WriteResponse(response) + return + } + } if v, ok := instance.(outcome.Response); ok { if v.StatusCode > 0 { diff --git a/lib/outcome/outcome.go b/lib/outcome/outcome.go index 3084db2..435c7a8 100644 --- a/lib/outcome/outcome.go +++ b/lib/outcome/outcome.go @@ -10,6 +10,10 @@ import ( "github.com/gofiber/fiber/v2" ) +type HTTPSerializer interface { + GetResponse() Response +} + type Response struct { ContentType string Data any