Skip to content

Commit 9d0e669

Browse files
committed
feat: Create Ctx.Req API
1 parent 109ccdd commit 9d0e669

File tree

25 files changed

+1358
-1169
lines changed

25 files changed

+1358
-1169
lines changed

app_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,7 +1666,7 @@ func Test_App_ReadBodyStream(t *testing.T) {
16661666
app := New(Config{StreamRequestBody: true})
16671667
app.Post("/", func(c Ctx) error {
16681668
// Calling c.Body() automatically reads the entire stream.
1669-
return c.SendString(fmt.Sprintf("%v %s", c.Request().IsBodyStream(), c.Body()))
1669+
return c.SendString(fmt.Sprintf("%v %s", c.Context().Request.IsBodyStream(), c.Body()))
16701670
})
16711671
testString := "this is a test"
16721672
resp, err := app.Test(httptest.NewRequest(MethodPost, "/", bytes.NewBufferString(testString)))
@@ -1683,7 +1683,7 @@ func Test_App_DisablePreParseMultipartForm(t *testing.T) {
16831683

16841684
app := New(Config{DisablePreParseMultipartForm: true, StreamRequestBody: true})
16851685
app.Post("/", func(c Ctx) error {
1686-
req := c.Request()
1686+
req := &c.Context().Request
16871687
mpf, err := req.MultipartForm()
16881688
if err != nil {
16891689
return err

bind.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func (b *Bind) Custom(name string, dest any) error {
7676

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

0 commit comments

Comments
 (0)