On Thursday, 7 May 2015 at 19:51:20 UTC, yawniek wrote:

On Thursday, 7 May 2015 at 18:59:13 UTC, Suliman wrote:
1. Do I need write "./public/" ? In examples often simply "public/"
will work too. even "public"
it goes trough Path struct, see:
https://github.com/rejectedsoftware/vibe.d/blob/11578aa956a9b3b0e305d655f9668a867fdd89bd/source/vibe/inet/path.d


2. What incoming parameters ("HTTPServerRequest req, HTTPServerResponse res") mean? Why I should to specify them?

HTTPServerRequest contains all data that the client sends, e.g.
headers, cookies, source ip etc.
see:
https://github.com/rejectedsoftware/vibe.d/blob/11578aa956a9b3b0e305d655f9668a867fdd89bd/source/vibe/http/server.d#L584

HTTPServerResponse is the response you send back.
https://github.com/rejectedsoftware/vibe.d/blob/11578aa956a9b3b0e305d655f9668a867fdd89bd/source/vibe/http/server.d#L788

you woud want to set at least its body, as you do below

3. Why code with: "res.writeBody("Hello, World!", "text/plain");" and "router.get("*", serveStaticFiles("./public/"));" also work, but my variant (see code above) do not load say that page not found?

what exactely does not work? please link code (ideally https://gist.github.com/ )

4. How to specify page that I need to load, why in examples there is only link to folder like public? But what if I want to load public/foo.html?

public servers public files, its more or less a static webserver which checks if a file exists and then serves that.

if you want to dynamically modify content you send you need to use the templating or do your own string magic.


generally it seems you do not fully understand the concept of how these web frameworks work. i think you should either read vibe.d's source code or more read how other such frameworks work e.g. http://www.sinatrarb.com/documentation.html has pretty good documentations and books that explain the inner workings (but mind, ruby is a dynamically typed language).

then i also can recommend that you check out vibe.d's github repositories and read trough all the example projects that come with it. e.g.
https://github.com/rejectedsoftware/vibe.d/tree/11578aa956a9b3b0e305d655f9668a867fdd89bd/examples/app_skeleton

I'd say it is a bit hard to get into vibe.d just like that. I had to work out a lot of things myself simply because it's web server technology cast in D. Most of the difficulties are not D but understanding the whole web server thing. But I have to say vibe.d is very very good once you know your way around. Maybe we should set up some tutorials with common tasks so developers can concentrate on D instead of the web.

Reply via email to