On Thursday, 7 May 2015 at 18:59:13 UTC, Suliman wrote:
shared static this()
{
        auto router = new URLRouter;
        router.get("/", &root);

        auto settings = new HTTPServerSettings;
    settings.port = 8080;
    listenHTTP(settings, router);
}


void root(HTTPServerRequest req, HTTPServerResponse res)
{
        serveStaticFiles("public/");
}

i missed this in the answer sorry,
its clear that its not working you are saying that
ONLY requests to "/"  shall be served with the staticFiles.
this makes no sense.
for static files you would want a catch all route at the end, and before that you define a few other routes that serve specific strings.

check this:
https://github.com/rejectedsoftware/vibe.d/blob/11578aa956a9b3b0e305d655f9668a867fdd89bd/examples/app_skeleton/source/app.d#L18

router.get("/", &showHome); // GET / is handled by the showHome function router.get("/about", staticTemplate!"about.dt"); // GET /about is handlet by the template router.get("*", serveStaticFiles("public")); // every other get request goes here and checks if a filename exists within the public folder. so e.g. GET /foo.html is either served public/foo.html if it exists or returns an 404

Reply via email to