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

Allow dynamic file-based checks in router #162

Closed
gber opened this issue Feb 28, 2013 · 8 comments
Closed

Allow dynamic file-based checks in router #162

gber opened this issue Feb 28, 2013 · 8 comments

Comments

@gber
Copy link

gber commented Feb 28, 2013

It would be useful if the new router supported dynamically checking for files like Apache's mod_rewrite with

RewriteCond         %{DOCUMENT_ROOT}/%{REQUEST_URI} -d/-f/-s/-l/-x

or nginx with

if (-f/-e/-x $request_filename) {

Note that in contrast to if-dir/if-file the checks would have to be performed at any request rather than during evaluation of the configuration file.

@prymitive
Copy link
Contributor

Doesn't --static-check, --static-map or other ---static-* options do that already?
Routers doesn't do anything more than passing requests to backend nodes, those nodes doesn't need to be on the same machine.

@unbit
Copy link
Owner

unbit commented Feb 28, 2013

I think he is referring to internal routing.

Basically it requires something like that:

route-if-file-exists = ${DOCUMENT_ROOT}/${REQUEST_URI} goto:foobar

i will check if there is a way to accomplish that without adding a new option

@gber
Copy link
Author

gber commented Feb 28, 2013

Yes, exactly that.

@gber
Copy link
Author

gber commented Feb 28, 2013

It'd be nice it it also allowed to check for directories/executable files as with mod_rewrite. That's e.g. useful for adding missing slashes:

route = /$ continue:
route-if-dir-exists = ${DOCUMENT_ROOT}/${REQUEST_URI} redirect-permanent:${DOCUMENT_ROOT}/${REQUEST_URI}/

@unbit
Copy link
Owner

unbit commented Mar 1, 2013

Added the "route_condition" subsystem. You can add new conditions with plugins too.

Currently supported conditions:

exists
isfile
isdir
islink

examples:

route-if = exists:${DOCUMENT_ROOT}/${REQUEST_URI} static:${DOCUMENT_ROOT}/${REQUEST_URI}
route-if = isfile:/var/www/${PATH_INFO} log:oops
route-if-not = exists:/test/foo break:500

@gber
Copy link
Author

gber commented Mar 1, 2013

Awesome! Would you mind adding an isexec condition?

@unbit
Copy link
Owner

unbit commented Mar 1, 2013

pretty easy:

a2e4c6e

@gber
Copy link
Author

gber commented Mar 1, 2013

Thanks again.

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

3 participants