Skip to content

Commit

Permalink
Use common fuego interface
Browse files Browse the repository at this point in the history
  • Loading branch information
EwenQuim committed Dec 20, 2024
1 parent fa575d9 commit a116c53
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
8 changes: 5 additions & 3 deletions examples/gin-compat/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,27 @@ import (
"github.com/gin-gonic/gin"

"github.com/go-fuego/fuego"
"github.com/go-fuego/fuego/extra/fuegogin"
)

func ginController(c *gin.Context) {
c.String(200, "pong")
}

func fuegoControllerGet(c fuegogin.ContextNoBody) (HelloResponse, error) {
func fuegoControllerGet(c fuego.ContextNoBody) (HelloResponse, error) {
return HelloResponse{
Message: "Hello",
}, nil
}

func fuegoControllerPost(c fuegogin.ContextWithBody[HelloRequest]) (HelloResponse, error) {
func fuegoControllerPost(c fuego.ContextWithBody[HelloRequest]) (HelloResponse, error) {
body, err := c.Body()
if err != nil {
return HelloResponse{}, err
}

ctx := c.Context().(*gin.Context)
fmt.Printf("%#v", ctx)

name := c.QueryParam("name")

return HelloResponse{
Expand Down
4 changes: 3 additions & 1 deletion extra/fuegogin/adaptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ func GinHandler[B, T any](handler func(c fuego.ContextWithBody[B]) (T, error)) g
return func(c *gin.Context) {
context := &ginContext[B]{
CommonContext: internal.CommonContext[B]{
CommonCtx: c,
CommonCtx: c,
UrlValues: c.Request.URL.Query(),
OpenAPIParams: map[string]fuego.OpenAPIParam{},
},
ginCtx: c,
}
Expand Down
1 change: 1 addition & 0 deletions go.work
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use (
./examples/custom-serializer
./examples/full-app-gourmet
./examples/generate-opengraph-image
./examples/gin-compat
./examples/hello-world
./examples/openapi
./extra/fuegogin
Expand Down

0 comments on commit a116c53

Please sign in to comment.