RejectedSoftware Forums

Sign up

Static Files

I am currently trying to serve static files...

// this one works
router.get("*", serveStaticFiles("./rcd/static/"));

// this one doesn't work
router.get("/static/*", serveStaticFiles("./rcd/static/"));

Any ideas why the second doesn't work, no files are served, it forwards
to the Error Handler with a 404 Not Found

Also the documentation: http://vibed.org/api/vibe.http.router/URLRouter
should probably be updated, (toDelegate, serveStaticFiles won't work
like that, also conflicts with http.server.fileserver)

Furthermore a search function for the docs would be really helpful, I
hate it when I have to grep through the source to find what I need, this
is normally happens only if the docs are bad, but I wouldn't say the
vibe docs are bad (but no comparison e.g. to flask).

Re: Static Files

On Sun, 12 May 2013 14:44:07 +0200, David wrote:

// this one doesn't work
router.get("/static/*", serveStaticFiles("./rcd/static/"));

In this case, the files will be searched in "./rcd/static/static/..." instead of "./rdc/static/...", because the file server has no knowledge of the pattern used to match the URL, it only knows the URL itself. So in this particular case using router.get("/static/*", serveStaticFiles("./rcd/")); should work, or, as a more general alternative, the URL prefix can be stripped by specifying a settings object:

auto settings = new HTTPFileServerSettings;
settings.serverPathPrefix = "/static/";
router.get("/static/*", serveStaticFiles("./rcd/static/", settings));

Furthermore a search function for the docs would be really helpful, I
hate it when I have to grep through the source to find what I need, this
is normally happens only if the docs are bad, but I wouldn't say the
vibe docs are bad (but no comparison e.g. to flask).

A search function/symbol index is planned, I'm just not sure when I'll actually manage to implement it. Another planned feature is to automatically embed hyperlinks in example code sections, which should also help a lot when trying to understand the examples in detail.

General improvement of the documentation is also always a topic, but of course this takes a lot of effort and time is currently a sparse resource for me with functionality taking precedence... so this will probably be more of a (slow) gradual process.

Re: Static Files

On Sun, 12 May 2013 14:44:07 +0200
David d@dav1d.de wrote:

Furthermore a search function for the docs would be really helpful, I
hate it when I have to grep through the source to find what I need,
this is normally happens only if the docs are bad, but I wouldn't say
the vibe docs are bad (but no comparison e.g. to flask).

Just add "site:vibed.org" to any google (or better yet, startpage.com)
search.