Skip to content

Commit 04948fd

Browse files
committed
wip: Create Ctx.Req API
1 parent 68780cd commit 04948fd

File tree

25 files changed

+1356
-1167
lines changed

25 files changed

+1356
-1167
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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func (b *Bind) Custom(name string, dest any) error {
7777

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

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

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

0 commit comments

Comments
 (0)