Skip to content

Commit

Permalink
wip: Create Ctx.Req API
Browse files Browse the repository at this point in the history
  • Loading branch information
nickajacks1 committed Apr 15, 2024
1 parent 68780cd commit 04948fd
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
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
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 {

Check warning on line 144 in bind.go

View check run for this annotation

Codecov / codecov/patch

bind.go#L144

Added line #L144 was not covered by tests
return err
}

Expand Down

0 comments on commit 04948fd

Please sign in to comment.