-
Notifications
You must be signed in to change notification settings - Fork 284
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
REST enhancement #1: Allow one to get parameters from headers #908
Conversation
- Add a string[string] headers__ local variable to the generated function; - If there's one and only one WebParamAttribute with the name of the parameter we're currently processing (as parameter gets processed in order), we add it to the AA, the key being the 'field' in WebParamAttribute; - headers__ gets later passed to request() which will add all it's field to the headers;
635f272
to
ca950a3
Compare
For the record, my unittests are here: (under Not complete yet though. And I got a cryptic linker failure when running
Will check what's going on. EDIT 437: Sooooooo, Vibe.d doesn't compile with DMD master. Will work on it. |
Re-reading (because I have forgotten everything, doh) |
@Dicebot : Was the code that bad ? ;-) |
No, sorry, I have read it through once to actually remember what we are speaking about and now I need time to actually do line-by-line implementation review. Hopefully this weekend. |
Good. There are plenty of comments but those are mostly matter of style and naming - actual feature looks useful and solid. |
42fc57b
to
f6f41cd
Compare
Thanks for the review ! I fixed the style issues. What's left is:
|
LGTM @s-ludwig btw, @Geod24 I am thinking that after majority of your enhancements are merged we should go for separating/rewriting http://vibed.org/docs#rest-interface-generator into detailed guide. Something that will help answer the question "how am I supposed to use all that stuff?". Willing to join? :) |
Sure ! :-) |
As soon as your planned enhancements are complete so that next vibe.d release comes with both features and explanation for them. |
I'll probably start writing something based on existing stuff I know and let you eventually take it over |
I have something on my mind about REST paths. I'll try to formalize that and e-mail you next week. That would be one of the 2 breaking change I plan for this module (The other one being the serialization). |
f6f41cd
to
73ed222
Compare
@@ -348,7 +350,7 @@ class RestInterfaceClient(I) : I | |||
import vibe.data.json : Json; | |||
import vibe.textfilter.urlencode; | |||
|
|||
Json request(string verb, string name, Json params, bool[string] param_is_json) const | |||
Json request(string verb, string name, Json params, bool[string] param_is_json, string[string] hdrs) const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: I'd use a vibe.inet.message.InetHeaderMap
here for efficiency (doesn't allocate for few or no headers).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in ref InetHeaderMap
that is of course..
Generally looks good AFAICS. |
@s-ludwig : Thanks for the suggestion, I switched to |
Okay thanks, merging (finally)! |
REST enhancement #1: Allow one to get parameters from headers
Yay, thanks ! |
This broke compilation on anything but dmd-2.066.1, see https://travis-ci.org/rejectedsoftware/vibe.d/builds/44058739. |
Did it ? From the error:
It looks like it was already broken (but not noticed) before: From a quick look, the fix seems trivial, will submit P.R. today. Thanks for your work on this ! |
see #927 |
As the title say, I reopen #867 here.
I accidentally deleted my (remote) branch, and Github won't let me re-open the P.R.
I re-pushed original code to #867 . This one is rebased (because of #871 ).
The only change from #867 is that I renamed
@fromHeader
to@headerParam
.I can revert that if needed, but I think we have 2 advantages here:
@fromHeader
only makes sense in a server context. The (D) interface is meant to describe a REST interface.@headerParam
makes sense in a server and client context.@HeaderParam
is what's used in Java Jersey (Example 3.14, scroll down a bit here: https://jersey.java.net/documentation/latest/user-guide.html#d0e1887 ).Pinging @Dicebot .