Skip to content
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

Support serve-static from express #1617

Open
3 tasks done
retrohacker opened this issue Feb 27, 2018 · 1 comment
Open
3 tasks done

Support serve-static from express #1617

retrohacker opened this issue Feb 27, 2018 · 1 comment
Assignees
Labels
Feature Needs Discussion Serve Label to identify bottlenecks for serve static

Comments

@retrohacker
Copy link
Member

  • Used appropriate template for the issue type
  • Searched both open and closed issues for duplicates of this issue
  • Title adequately and concisely reflects the feature or the bug

Feature Request

Use Case

It would be super cool if we could just use the serve-static plugin from the express ecosystem instead of continuing to invest in maintaining a parallel (and broken) internal serveStatic plugin.

Why do you want this?

Example API

var restify = require('restify');
var serveStatic = require('serve-static');

var app = restify.createServer();
var serve = serveStatic('./static');

app.get('.*', function(req, res, next) {
    res.addListener('finish', next);
    serve(req, res, function (err) {
        res.removeListener('finish', next);
        next(err);
     });
});

app.listen(8080);

It also looks like we need to support the req.originalUrl pattern similar to express: https://github.com/expressjs/express/blob/c0136d8b48dd3526c58b2ad8666fb4b12b55116c/lib/router/index.js#L172

This should include code snippets and documentation for the proposed feature

Are you willing and able to implement this?

"Yes" or, if "no", what can current contributors do to help you create a PR?

Yup!

@kokarn
Copy link

kokarn commented Mar 4, 2018

This looks very promising!

Would this allow us to have say a static folder with some files served that way and the rest of the routes served by Restify itself?

My use case is that a pretty common scenario is to have a bunch of static files i'd like to serve, robots.txt, analytics auth and so on and the easiest way would be to have a static folder with that, and all the other routes just configured as per usual.

@hekike hekike added the Serve Label to identify bottlenecks for serve static label Apr 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Needs Discussion Serve Label to identify bottlenecks for serve static
Projects
None yet
Development

No branches or pull requests

3 participants