New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Serving Static content #28
Comments
Hi, No this should definitely work (I do it). Here's a gist with a crude "serve up API docs from ./docs" set of routes from one of my projects. Not the most elegant (or error-resistant), but it should get you going: https://gist.github.com/1056404 Anyway, I'll leave this ticket open to fix the docs since you're the second or third person that's asked about this. Also, do you have a stack trace ? (if it's throwing TypeError because you're sending a buffer into res.send() et al, that's what it should do - if it's something else I'll clean it up). m |
Closing this out. |
I case anyone else comes here for the same reason, I had at least initial success with the following (using restify 1.1.1): var static = require('node-static');
file = new static.Server('./public');
server.get(/^\/.*/, function(req, res, next) {
file.serve(req, res, next);
}); |
@mullr's is great; the included static server almost as good, but it doesn't serve the index as I would expect. |
@tlevine To server up index, I used the built in static server server.get /\/*/, restify.serveStatic directory: './static' and then added early on server.pre (req, res, next) ->
req.url = '/index.html' if req.url is '/'
next() |
Great work, I've just finished my API but now i want to put a placeholder webpage for the ones who visits the root.
I've managed to send text fine but when i try to serve images or another binaries it crashes...
any idea on how to solve this? or how to bind this to a static server like node-static at the same port as restify?
thanks.
The text was updated successfully, but these errors were encountered: