Am 10.02.2014 20:24, schrieb Frank:
Hello guys and (girls) to be political correct (it is a bis movement here in germany),
i am really new to vibe.d and the D programming language but very impressive
Look for a alternative for Scala (very slow compile time) and D seems to be a good candidate.Try to build a simple rest api with vibe.d see (https://github.com/pussinboots/dfirstweb/blob/master/source/app.d).
I need a possibility to set the http header "Access-Control-Allow-Origin" and
try it with the @after feature but i have a problem to define it for a void method.@after!addAccessControlOrigin() void getInfo(); void addAccessControlOrigin(HTTPServerRequest, HTTPServerResponse res) { res.headers["Access-Control-Allow-Origin"] = "*"; }
But the compile say no "Input attribute function addAccessControlOrigin(HTTPServerRequest, HTTPServerResponse) argument list does not match provided argument list void, HTTPServerRequest, HTTPServerResponse". I will commit the non working code to git in the next days. But i hope the
example show what i want.Maybe some of you have an advice like void method are not supported at the moment than i will
look in the vibe.d code and prepare a patch.Thanks for listen and answer
As a workaround, you could also use the URLRouter
to set the header:
router.any("*", &setAccessControlOrigin);
router.registerRestInterface(...);
This will also avoid having to repeat the @after
annotations.
In the long run, this will need to be implemented directly in the REST
interface generator, including a check for the actual origin of clients.
I've opened two issues for this:
#546,
#547