I am still trying to understand how to server static page. I looked at examples, but I do not understand why modified code co not work:
import std.stdio;
import vibe.core.core;
import vibe.core.log;
import vibe.http.router;
import vibe.http.server;
import vibe.http.fileserver;
import vibe.web.rest;
void main()
{
auto router = new URLRouter;
router.get("/", &index);
auto settings = new HTTPServerSettings;
settings.port = 8080;
listenHTTP(settings, router);
runEventLoop();
}
void index(HTTPServerRequest req, HTTPServerResponse res)
{
res.redirect("/index.html");
}
It's clear, that code do not have serveStaticFiles
part, so it would now work.
Example include line:router.get("*", serveStaticFiles("./public/",));
but I can't understand why after handling index.html
I should handle all ("*") requests?
Please explain me why I should write in such way, I do not see any logic here.