Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Improve static asset middleware #679

Closed
jlecomte opened this Issue · 6 comments

4 participants

@jlecomte
Owner

Only a small number of assets (favicon.ico, robots.txt and crossdomain.xml) can be served from the root path of a mojito application. This is not very flexible. Ideally, I would like to be able to specify "routes" to serve any file from pretty much any path. Also, I may want to set specific response headers on specific files. I don't have an exact list of requirements, and this is not a very high priority for me since I serve most of my static assets from CDN and can rewrite the URL of those I want to serve from the app server. However, this enhancement might be useful to the community.

@caridy
Owner

This sounds like a feature we introduced few days ago to support synthetic files. You should be able to create a RS addon to define any custom url, and a customizable way to produce the content of the file. In other words, u should be able to came up with any client url that will use a custom method to read, potentially compile the content, and define the headers for that particular resource.

@isao

It'd be nice to define a static route directly in routes.json without user code. Perhaps a convention for the routes.json "action" field to indicate a filesystem directory, plus a new field for http response headers (another long standing feature request).

@jlecomte
Owner

Isao, yes, that is exactly what I was talking about.

@caridy
Owner

I like that, easy to use, etc. But still I don't expect people to define favicon.ico in the routes everytime, we should have support for the basic ones out of the box.

@ooskapenaar

@Caridy, it would be great to have an example of such a RS addon. Currently we just patched the url.js to include the common site map.xml file (in the list of static routes). It would be great to do this correctly with our own addon.

Using 0.5.0.

@caridy
Owner

in mojito-next (0.9.x), you can now use express directly to serve those special files without having to mess with RS.

@caridy caridy closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.