Skip to content

Commit

Permalink
http serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
iesreza committed Jan 6, 2025
1 parent a3321dd commit 17a8233
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions evo.context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions lib/outcome/outcome.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import (
"github.com/gofiber/fiber/v2"
)

type HTTPSerializer interface {
GetResponse() Response
}

type Response struct {
ContentType string
Data any
Expand Down

0 comments on commit 17a8233

Please sign in to comment.