-
Notifications
You must be signed in to change notification settings - Fork 31
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
Allow reply with JsonDocument or JsonObject or JsonArray? #171
Comments
That is definitely doable. was think about the same. With the new refactoring in V2, it would help avoid dealing with a decorator class. The content type could be made optional, and if provided, could help switch between message pack and normal json. this approach could be the same also for several other types, Stream included. |
I'm thinking about something like this esp_err_t PsychicRequest::reply(int code, JsonDocument &doc)
{
PsychicResponse response(this);
response.setCode(code);
response.setContentType("application/json");
response.setContent(doc);
return response.send();
} void PsychicResponse::setContent(JsonDocument &doc)
{
serializeJson(doc, _body);
setContentLength(strlen(_body));
} |
We need to call only this |
Ct has to be optional since the same JsonVariant object can be serialised as message pack also ;-) |
Yeah, I see |
I wonder if it would be doable to reply directly with a JsonDocument in a cb.
Here is one of my endpoint controller method.
Would be good to do it like this
The text was updated successfully, but these errors were encountered: