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

Add HTTP::Request#form_params #13418

Merged
merged 4 commits into from
Jun 15, 2023

Conversation

threez
Copy link
Contributor

@threez threez commented May 1, 2023

The current API has helpers to get the query params for an HTTP request. I was searching io how to handle
a regular http post. I did not find an direct answer, again searching the docs. After a little while I noticed that there are outdated examples on stack overflow. To safe everybody else the hassle of searching how to get form params, I added
convenience helpers in the spirit of query_params.

This will enable uses like this:

require "http/server"

class SomeHandler
  include HTTP::Handler

  def call(context)
    if params = context.request.form_params?
      # do something with
      puts params["some"]?
    end
  end
end

src/http/request.cr Outdated Show resolved Hide resolved
@straight-shoota
Copy link
Member

@threez Would you mind adressing the review comment?
If you don't want to continue with this PR, please let us know and someone else will take over.

@threez
Copy link
Contributor Author

threez commented Jun 8, 2023

@straight-shoota, sorry for late reply. I added the changes as requested.

@threez threez requested a review from HertzDevil June 13, 2023 19:15
@straight-shoota straight-shoota added this to the 1.9.0 milestone Jun 14, 2023
@straight-shoota straight-shoota changed the title add form_params for HTTP::Request Add HTTP::Request#form_params Jun 15, 2023
@straight-shoota straight-shoota merged commit 77c8cee into crystal-lang:master Jun 15, 2023
50 checks passed
Blacksmoke16 pushed a commit to Blacksmoke16/crystal that referenced this pull request Dec 11, 2023
Co-authored-by: Quinton Miller <nicetas.c@gmail.com>
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.

None yet

4 participants