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
New input/query API #247
Comments
@manucorporat, I'd like to make the request that ParseForm is lazily called on the first call that requires it. |
@itsjamie of course! ParseForm would be lazily called |
@manucorporat This definitely reduces the amount you need to directly call on the net/http methods. If you don't mind me asking, what do you feel the cost to the framework is for introducing this functionality? What is the benefit? I really like how Gin currently focuses on providing a nice implementation of handling middleware, and provides some convenience method for oft-used functionality that has a slightly nicer API than the underlying tech (like httprouter). I just want to make sure that any code you decide to add to part of core is following the vision you want the project to take. |
Personally, I feel this is right in line with what I feel Gin should accomplish (btw). |
@itsjamieI totally agree with you.
This new API will have 0 overhead, otherwise I would not include it!
Gin focuses in a good balance of performance and convenience. A typical request in httpRouter can be handled in 220ns (in my machine), Gin only adds 30ns of overhead in average. But as you know, Gin provides an much nicer environment: middlewares, content negotiation, parsing, validation.... I want to continue optimizing the most common use cases such us the user input through a form, and I think we need a better API for that. |
Will the intelligent one |
@leedstyh I dropped this feature because it introduces very complex situations. |
As @manucorporat say, we should close the issue, right? @appleboy |
@thinkerou OK. |
I want to provide a better API to get the input parameters from the path, POSTForm and GETForm.
Let's say, we register this route:
and we expect to receive requests like this:
Right now, you would have to do this in order to get the parameters:
c.Request.ParseForm()
)The new proposal:
Also,
c.Input
will implement an intelligentGet()
method that takes the value from the proper source. This feature is implemented in popular frameworks like laravel.One more thing, c.Input can be printed directly with
fmt.Print()
providing a useful debugging tool.The text was updated successfully, but these errors were encountered: