Thursday, 5 September 2013

Rewrite URL WIth restify, a few questions

Rewrite URL WIth restify, a few questions

My folder structure goes like this:
..
„¥„Ÿ„Ÿ backend
„  „¤„Ÿ„Ÿ node_modules
„¤„Ÿ„Ÿ frontend
„¥„Ÿ„Ÿ bower_components
„¥„Ÿ„Ÿ controllers
„¥„Ÿ„Ÿ layouts
„¥„Ÿ„Ÿ models
„¥„Ÿ„Ÿ public
„¥„Ÿ„Ÿ templates
„¤„Ÿ„Ÿ views
now on the restify server.js i'm trying to serve static files from a few
different folders,
public - here i have index.html file and a js folder that contain a loader
for the main modules requirejs and all the sass pre-compiled code.
templates - i'm using require-text to load templates into a module
server.get(/.*\.html/, restify.serveStatic({
"directory": "../frontend/public",
"default": "public/index.html"
}));
server.get(/templates\/.*\.html/, restify.serveStatic({
"directory": "../frontend"
}))
now every thing was work greate until i add the line that should take
control on the templates directory.
This is the error i'm getting when trying to access this resource:
{"code":"ResourceNotFound","message":"/templates/VideoItem.html"}
my first question is why this is not working?
the second question is how do i rewrite the url, i don't want to use the
real paths of the files, serveStatic is expecting that the path i'm
passing will be a suffix for the directory parameter.
Thanks (hope my english is understandable)

No comments:

Post a Comment