Need help with delegates and vibed
Alex Parrill via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Mar 19 14:06:24 PDT 2016
On Saturday, 19 March 2016 at 19:53:01 UTC, Suliman wrote:
> Thanks! I am understand a little bit better, but not all.
>
> ```
> shared static this()
> {
> auto settings = new HTTPServerSettings;
> settings.port = 8080;
>
> listenHTTP(settings, &handleRequest);
> }
>
> void handleRequest(HTTPServerRequest req,
> HTTPServerResponse res)
> {
> if (req.path == "/")
> res.writeBody("Hello, World!", "text/plain");
> }
> ```
> https://github.com/rejectedsoftware/vibe.d/blob/master/source/vibe/http/server.d#L104
> I expected to see in listenHTTP() function some processing but
> it's simply get args and then do return:
> return listenHTTP(...)
>
> Could you explain why it's do so?
>
> --
> Where is constructor of this class?
> http://vibed.org/api/vibe.http.client/HTTPClientRequest
>
> How I should use it if have only docs, and do not have
> examples? (I am trying understand how to use docs without
> cope-past examples)
The function is overloaded; it's calling the main implementation
at line 77 after transforming the arguments.
The constructor for HTTPClientRequest is likely undocumented
because you should not construct it yourself; vibe.d constructs
it and passes it to the function you register with listenHTTP.
More information about the Digitalmars-d-learn
mailing list