Skip to content

Commit

Permalink
feat: Create Ctx.Req API
Browse files Browse the repository at this point in the history
  • Loading branch information
nickajacks1 committed Apr 21, 2024
1 parent 4d1e993 commit 8dbd147
Show file tree
Hide file tree
Showing 25 changed files with 1,356 additions and 1,167 deletions.
4 changes: 2 additions & 2 deletions app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1666,7 +1666,7 @@ func Test_App_ReadBodyStream(t *testing.T) {
app := New(Config{StreamRequestBody: true})
app.Post("/", func(c Ctx) error {
// Calling c.Body() automatically reads the entire stream.
return c.SendString(fmt.Sprintf("%v %s", c.Request().IsBodyStream(), c.Body()))
return c.SendString(fmt.Sprintf("%v %s", c.Context().Request.IsBodyStream(), c.Body()))
})
testString := "this is a test"
resp, err := app.Test(httptest.NewRequest(MethodPost, "/", bytes.NewBufferString(testString)))
Expand All @@ -1683,7 +1683,7 @@ func Test_App_DisablePreParseMultipartForm(t *testing.T) {

app := New(Config{DisablePreParseMultipartForm: true, StreamRequestBody: true})
app.Post("/", func(c Ctx) error {
req := c.Request()
req := &c.Context().Request
mpf, err := req.MultipartForm()
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (b *Bind) Custom(name string, dest any) error {

// Header binds the request header strings into the struct, map[string]string and map[string][]string.
func (b *Bind) Header(out any) error {
if err := b.returnErr(binder.HeaderBinder.Bind(b.ctx.Request(), out)); err != nil {
if err := b.returnErr(binder.HeaderBinder.Bind(&b.ctx.Context().Request, out)); err != nil {
return err
}

Expand Down Expand Up @@ -141,7 +141,7 @@ func (b *Bind) Form(out any) error {

// URI binds the route parameters into the struct, map[string]string and map[string][]string.
func (b *Bind) URI(out any) error {
if err := b.returnErr(binder.URIBinder.Bind(b.ctx.route.Params, b.ctx.Params, out)); err != nil {
if err := b.returnErr(binder.URIBinder.Bind(b.ctx.req.route.Params, b.ctx.Params, out)); err != nil {
return err
}

Expand Down
Loading

0 comments on commit 8dbd147

Please sign in to comment.