Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent panic in Context.GetQuery() when there is no Request #2412

Merged
merged 3 commits into from Aug 8, 2020

Commits on Jun 16, 2020

  1. Prevent panic in Context.GetQuery() when there is no Request

    I have an endpoint that uses an optional query parameter via DefaultQuery(). 
    In one unit test case I want to test the route with that parameter.
    I write that test as
    ```go
    	w := httptest.NewRecorder()
    	c, _ := gin.CreateTestContext(w)
    	routeHandler(c)
    ```
    And this panics when routeHandler() calls c.DefaultQuery() because c.Request == nil.
    pofl committed Jun 16, 2020
    Copy the full SHA
    8cd66f7 View commit details
    Browse the repository at this point in the history
  2. Copy the full SHA
    5186e18 View commit details
    Browse the repository at this point in the history

Commits on Aug 8, 2020

  1. Copy the full SHA
    b453ed1 View commit details
    Browse the repository at this point in the history