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

[RFC] vibe.web.web: Support JSON more natively #1697

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wilzbach
Copy link
Member

@wilzbach wilzbach commented Feb 27, 2017

A couple of improvement ideas to help working with Json:

@s-ludwig
Copy link
Member

The direction definitely makes sense. What I had in mind for quite a while now was to let the REST and web interface generators share more code - maybe in the form of using RestInterface!T also for web interfaces (with a few adjustments). This means that specifying a whole-body JSON parameter in web interfaces would work the same as for RESTful interfaces: @bodyParam("p") void fun(Json p) {}.

One reason for going that route (apart from strengthening the least-surprise factor) is that I recently had a lot of places where having @queryParam and @bodyParam in the web interface would have been really useful.

@wilzbach
Copy link
Member Author

The direction definitely makes sense.

As this stalled a bit in the queue, I have split this PR into three pieces which should make it a lot easier to evaluate them in small pieces (I think the split-offs are non-controversial, only this one might be).

This means that specifying a whole-body JSON parameter in web interfaces would work the same as for RESTful interfaces: @bodyParam("p") void fun(Json p) {}.

I agree that this wouldn't be bad, but Json is so commonly nowadays that I would prefer void fun(Json p){} (#1853) or even auto-deserialization from Json: void fun(MyStruct myStruct) (this PR)

@wilzbach
Copy link
Member Author

wilzbach commented Apr 2, 2018

This means that specifying a whole-body JSON parameter in web interfaces would work the same as for RESTful interfaces: @bodyParam("p") void fun(Json p) {}.

FYI: this might soon be void fun(@bodyParam Json p){} - the respective language change has already been approved and a working PR is in the queue (dlang/dmd#7576). It just needs a few final tweaks, so if you want to I could with-hold the param changes and make this PR, s.t. it's just about allowing to return a arbitrary type in vibe.web.web which in turn will be serialized to Json.

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

Successfully merging this pull request may close these issues.

2 participants