-
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
JavaScript based REST interface client #1209
Conversation
Any ETA for when you want this ? I'll review by the end of this week.
Though at first sight it looks like a there's a fair amount of duplication ?
|
I have actually started to work on the duplication issue (which is already present even without this addition), but the current I'll probably create a 0.7.24 branch during the next couple of days and start merging your remaining changes in |
b454c2c
to
cc0d0a4
Compare
Cleaned up the commit history for review. |
61c6209
to
b1bc236
Compare
header, // req.header[] | ||
attributed, // @before | ||
internal // req.params[] | ||
} |
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.
IIUC, internal is for path attribute, isn't it ? Maybe that'll be a more descriptive name. Also body parameters are not meant to stay JSON forever. On that topic: any way to check the server setting ? It's not a big deal, but if someone disable parseQueryString
for example, there's no way to detect it.
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.
It's for path attributes or any other attributes that are passed using req.params
. Since there are valid uses outside of path placeholders, I decided against using that as the name. With the "JSON" comment I just wanted to describe the current state, since I'm not sure yet how to best handle multiple formats in terms of the internal architecture.
Currently there is no way to check the server settings. Really the only possibility that I see would be to throw an exception from inside HTTPServerRequest
if the .json
field is accessed without the parseJson
setting. Another, probably better, path would be to switch the whole JSON body parsing to happen lazily and optionally strongly typed.
Hum, another P.R. blocked by 2.065 :( Also, it looks like there's a discrepancy between the client and server with the refactoring: REST route: GET /root/get_check/:param/:param2 []
add route GET /root/get_check/:param/:param2
[...]
no route match: GET /root/getCheck/one/two
No response written for /root/getCheck/one/two
REST call: GET http://127.0.0.1:8000/root/getCheck/one/two -> 404, 404 For the rest, the diff is large, so I'll probably have to try it out on my machine to be sure, but I like where it's heading at. I'm not that familiar with JS, but the new functionality looks cool 👍 |
Rebased on master. I've also fixed the handling of optional parameters. Commit ca3def1 needs some re-review, because during rebase it was just a single big conflict with the write-to-headers change. Apart from that, everything except the default service URL comment and the possible merge of I'll have a look at the latter now. Regarding the URL, I don't remember exactly anymore, but I think I got some internal assertions due to an empty service URL, which was quite unobvious for the user. We could alternatively use something like |
@Geod24, did you see any remaining issues? Otherwise I'd rebase/squash and merge now. |
I'll do a last sweep this evening ;) |
Can't see anything. |
I haven't tested all of them yet, but I'll do that now. |
6997c4c
to
eebf993
Compare
…m the generator. The RestInterface struct is suitable to implement all REST interface generators with minimal boilerplate code. It avoids the high level of redundancy that is prevalent among the different implementations today.
eebf993
to
68d5322
Compare
Okay, when testing my projects I found one bug in the REST client (09ee6a2), but none in the new code. Will merge once Travis goes green. |
JavaScript based REST interface client
And thanks for reviewing this lengthy change set! |
I would have loved to review this but got caught up in the busiest time of the past few years. Sorry! |
// XHR setup | ||
output.put(" var xhr = new XMLHttpRequest();\n"); | ||
output.formattedWrite(" xhr.open('%s', url, true);\n", route.method.to!string.toUpper); | ||
static if (!is(RT == void)) { |
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.
Sorry for not catching this sooner, but is RT
actually defined here? I think it's causing this block to execute regardless of return type.
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.
Thanks, looks like that... is()
and __traits(compiles)
are really suboptimal constructs w.r.t. correctness. I'll add a test and fix this.
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.
Err.. or rather just merge your PR and add a test ;)
No description provided.