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

Path prefix matching for routes #170

Closed
mjg123 opened this issue Jul 28, 2017 · 4 comments
Closed

Path prefix matching for routes #170

mjg123 opened this issue Jul 28, 2017 · 4 comments

Comments

@mjg123
Copy link

mjg123 commented Jul 28, 2017

It'd be great to be able to treat a route as a prefix when matching, rather than having to match exactly. For example:

  /r/my_app/some-path-prefix/<anything>/<at>/<all>  ->  myfn

This doesn't mandate that path params to be evaluated by the fn platform, as long as the entire request URL is passed into the function we can do that ourselves.

This request would be especially useful for https://github.com/bbilger/jrestlesss - we can define an application with a base-url and many sub-resources hosted in a single function. This is hard work at the moment as we need to create a lot of routes in the fn platform, and are not able to dynamically add a route at runtime.

@hibooboo2
Copy link
Contributor

Why wouldn't you be able to add a route at runtime @mjg123 ?

@mjg123
Copy link
Author

mjg123 commented Jul 29, 2017

Hi there. By "dynamically" I mean that the function wouldn't be able to create new routes for itself depending on (eg) something from a data store.

For example a path-prefix/users/<user_id>/details URL where new <user_id> values can be created at runtime. AIUI the current behaviour is that all the possible values for <user_id> would need to have routes manually created.

This isn't really a separate requirement - we would like to have a single prefix (eg /r/my_app/some-path-prefix/) mapped to a function so that /r/my_app/some-path-prefix/<anything>/<at>/<all>?with=params would be sent to it.

@rdallman
Copy link
Contributor

related to this iron-io/functions#77

@Empty2k12
Copy link

One example of a use case for this is a function that serves a static file: You'd expect the filepath to look something like domain.local/static/main.css but this is currently not possible with fn. Instead I have to resort to hacky file serving aka domain.local/static?file=main.css which works but is semantically bad.

Another example is a function serving a Single Page Application that works with client-side routing á la React Router. I want the root function to be able to read the path and respond based on that (e.g. domain.local/show/all or domain.local/show/1 handled by JavaScript and not server side)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants