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

[Bug] Fix query string parameter pass to fiber context #2164

Merged
merged 2 commits into from
Oct 20, 2022

Conversation

joseroberto
Copy link
Contributor

@joseroberto joseroberto commented Oct 20, 2022

Description

Remove this change (#1909).

Fix test when using query string parameter.

When you use /foo?bar=boo, your test case should able to QueryParser parameter from fiber.Ctx:

func ListResource(c *fiber.Ctx) error {
        mrf := new(models ResouceFilter)
	if err = c.QueryParser(mrf); err != nil {
		return sendError(c, http.StatusBadRequest, err)
	}

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • For new functionalities I follow the inspiration of the express js framework and built them similar in usage
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation - https://github.com/gofiber/docs for https://docs.gofiber.io/
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • If new dependencies exist, I have checked that they are really necessary and agreed with the maintainers/community (we want to have as few dependencies as possible)
  • I tried to make my code as fast as possible with as few allocations as possible
  • For new code I have written benchmarks so that they can be analyzed and improved

@welcome
Copy link

welcome bot commented Oct 20, 2022

Thanks for opening this pull request! 🎉 Please check out our contributing guidelines. If you need help or want to chat with us, join us on Discord https://gofiber.io/discord

@ReneWerner87
Copy link
Member

@ancogamer the change in the pull request before is from you, can you check if this is correct here or give background information

@@ -883,11 +882,6 @@ func (app *App) Test(req *http.Request, msTimeout ...int) (resp *http.Response,
return nil, err
}

// adding back the query from URL, since dump cleans it
dumps := bytes.Split(dump, []byte(" "))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the description and title of the PR should be filled in according to pull request template .

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about that!!!

@ancogamer
Copy link
Contributor

@ancogamer the change in the pull request before is from you, can you check if this is correct here or give background information

Hi, sorry for the late, the problem was, only the url was processing, so if you tried to use some query params (?foo:bar), it was simply ignored, so what i did was just manipulate the result string to add those.

@ReneWerner87
Copy link
Member

but is this change okay or not ?

@ancogamer
Copy link
Contributor

Dont see any problem, but the response of Test wont have anymore the query on it. @joseroberto can you show a example of how to get those values on test case ?

@joseroberto
Copy link
Contributor Author

joseroberto commented Oct 20, 2022

@ancogamer Dear, your change suppresses query string parameter's to be passed throw the context.

dumps[1] = []byte(req.URL.String()). <---- this remove all the URI query string

Before: /foo?bar=boo
After: /foo

func xxx(c *fiber.Ctx) error {
	err = c.Query("bar");  <-- It should not be empty and it is with your modification
}

@joseroberto joseroberto changed the title Fix query string parameter pass to fiber context [Bug] Fix query string parameter pass to fiber context Oct 20, 2022
@ancogamer
Copy link
Contributor

Well, @ReneWerner87 to me this change looks fine. Sorry for the problens, i dont know why, but when i add it, the DumpRequest, wasn't returning the ?query, looks like it was fixed.

@ReneWerner87
Copy link
Member

Ok thx for the clarification

@ReneWerner87 ReneWerner87 merged commit 917c937 into gofiber:master Oct 20, 2022
@welcome
Copy link

welcome bot commented Oct 20, 2022

Congrats on merging your first pull request! 🎉 We here at Fiber are proud of you! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants