-
Notifications
You must be signed in to change notification settings - Fork 890
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
any JSON object should be allowed; another ctor for response object #250
base: master
Are you sure you want to change the base?
Conversation
@ipkn - I think the missing documentation project really needs some attention. Let me know if you need help. |
It seems that current response code has a bug at handling json value. Some constructors save json_value only and some others serialize to the body right away. This problem should be handled first. I think that the best way is remove json_obj from response class and add a static method named response_from_json_string. Add another constructor with bool argument seems error-prone to me. And I also want to add a customizable `response serialization' class with enable_if. Then rapidJSON or nlohmann json can works well with response class. Code will be something like this:
Any documentation help is always welcome. I'm still busy and deeply appreciate for any help. |
@ipkn - I follow you argument here. Although I think it un-necessarily complicates things for the end-user of crow. The
Let me know what you think. |
The thought about having a constructor with json value was: If we can construct the response from a json object, we can write a handler just with a json return value and without a response argument.
This looks good for writing a simple rest server. But maybe giving headers as a constructor argument could be better. Many other web server implementations create a response obj from [status code, body, headers]. I will do some more experiments later and make suggestions again. |
CROW_ROUTE(app, "/api/mutil_json")
/* |
It was not correct to allow only JSON object type to be serialized like that since other things are also valid JSON.
Since you mention people can use rapidJSON you need a way for them to pass std::string but still set the header content-type to be JSON for client applications.