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

Parameters is empty #4

Closed
numbcoder opened this issue Mar 30, 2016 · 8 comments
Closed

Parameters is empty #4

numbcoder opened this issue Mar 30, 2016 · 8 comments

Comments

@numbcoder
Copy link

Parameters is an empty hash when post with json, but the params is correct

POST /posts HTTP/1.1
Content-Type: application/json
Host: localhost:3000
Connection: close
User-Agent: Paw/2.3.2 (Macintosh; OS X/10.11.4) GCDHTTPRequest
Content-Length: 17

{"title":"hello"}
curl -X "POST" "http://localhost:3000/posts" \
    -H "Content-Type: application/json" \
    -d "{\"title\":\"hello\"}"
Started POST "/posts" at 2016-03-30 17:02:17 +0800
Processing by PostsApi#posts
  Parameters: {}
Completed 500 in 1.05ms
@ridiculous
Copy link
Owner

I was able to reproduce using the https://github.com/ruby-grape/grape-on-rack example using Grape (v0.14.0). Not sure what's going on yet. I swear it used to work ...

@ridiculous
Copy link
Owner

What version of Grape and Ruby are you using?

@numbcoder
Copy link
Author

Grape 0.15.0
Ruby 2.3.0


Not work using Grape 0.14.0

ridiculous added a commit that referenced this issue Apr 1, 2016
- Call the formatter middleware manaully to parse env['rack.input'] and set the grape request body early
- Overload the formatter's #before method so we don't parse the input twice
- Wouldn't be an issue if Grape::Endpoint would #use custom middleware after using formatter
@ridiculous
Copy link
Owner

You wanna try the latest master and see if it's fixed for you? If it is, I'll cut a new gem version with the changes.

@numbcoder
Copy link
Author

works in this commit 41eeaaa, but master is not work

request_params can get from env[Grape::Env::RACK_REQUEST_FORM_HASH] 41eeaaa#diff-d37acfdf2e7dc7daf14345bf49cc9b79R89

My project stack: Rails 5.0.0.beta3 + Grape 0.15.0

Thanks!

@ridiculous
Copy link
Owner

Oh your using this with Rails?! We should be getting the params from env['action_dispatch.request.request_parameters'] ... I haven't tested it with Rails 5, maybe they changed the env key. Are you requiring rails in your Gemfile before grape-middleware-logger?

@ridiculous
Copy link
Owner

I added back the functionality present in 41eeaaa. You want to try the latest master now? 6c2559c

@numbcoder
Copy link
Author

works!

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

No branches or pull requests

2 participants