Skip to content

Instantly share code, notes, and snippets.

@techwraith
Created November 3, 2012 04:45
Show Gist options
  • Save techwraith/4006019 to your computer and use it in GitHub Desktop.
Save techwraith/4006019 to your computer and use it in GitHub Desktop.
// Send a static file path
sendStaticFile = function (p) {
staticResp = new response.Response(resp);
// May be a path to a directory, with or without a trailing
// slash -- any trailing slash has already been stripped by
// this point
if (fs.statSync(p).isDirectory()) {
// TODO: Make the name of any index file configurable
<<<<<<< HEAD
p = path.join(p, 'index.html');
if (utils.file.existsSync(p) && fs.statSync(p).isFile()) {
staticResp.sendFile(p);
}
}
// Path to an actual file. Just serve it up
else if (fs.statSync(p).isFile()) {
staticResp.sendFile(p);
=======
staticPath = path.join(staticPath, 'index.html');
if (utils.file.existsSync(staticPath) && fs.statSync(staticPath).isFile()) {
controller = new StaticFileController(staticPath, reqObj, respObj);
controller.respond();
}
}
// Path to an actual file. Just serve it up
else if (fs.statSync(staticPath).isFile()) {
controller = new StaticFileController(staticPath, reqObj, respObj);
controller.respond();
>>>>>>> master
}
};
// If the path is in the static file path send it
if (utils.file.existsSync(publicPath)) {
sendStaticFile(publicPath);
}
// If the path includes the full partials path and is in the partials file in views send it
else if (staticUrl.match('partials/') && utils.file.existsSync(partialsPath)) {
sendStaticFile(partialsPath);
}
// Must be a 404 or 405
// 405?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment