knutin / elli

Simple, robust and performant Erlang web server
MIT License
663 stars 79 forks source link

post_args returns error badarg for content-type application/json. #97

Closed shamis closed 8 years ago

shamis commented 8 years ago

It would be nice if it just gave the data without parsing if the content type is json in the body_qs funciton

andreashasse commented 8 years ago

Hey, Thanks for the input. It seems to me that post_args and post_args_decoded are convenience functions that return a proplist for data that can be represented as a proplist. Json, in the general case, doesn't map well to proplists. Changing the return type of this function to proplists or binary makes this function, in my opinion, harder to understand and use. Another reason for elli not parsing json is that the different json parsers in erlang have very different run time behaviours, hence the choice of json parser have been left to the user of elli. If you want the body unparsed, use elli_request:body/1, that is how most projects that use elli is handling requests with json in the body. I hope this works out in your project :)

shamis commented 8 years ago

I had forgot about the body/1. Thanks this helped :+1: