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

Overlapping routes #294

Closed
jeff-h opened this issue Feb 20, 2018 · 4 comments
Closed

Overlapping routes #294

jeff-h opened this issue Feb 20, 2018 · 4 comments

Comments

@jeff-h
Copy link

jeff-h commented Feb 20, 2018

Similar to the example code:

server["/desktop/:path"] = shareFilesFromDirectory("/Users/me/Desktop")

I would like to do something like this (but it doesn't work, even reversing the order of the two statements):

server["/:path"] = shareFilesFromDirectory("/Users/me/Sites/test")
server["/vendor/:path"] = shareFilesFromDirectory("/Users/me/Sites/vendor")

This would enable the HTML inside the test directory to assume it's in the web root, and would also allow it to reference vendor libs (eg jQuery) from /vendor/jquery.js.

Unfortunately Swifter doesn't allow this, as it seems the first handler whose regex matches the path will be used, even if it returns a 404.

Symlinks might be a solution except I have other factors which preclude them.

So my question is: is it possible to craft a symlink to match all, but to preclude a specific path? eg something like:

// match anything, so long as it doesn't begin with `/vendor` 
server["!{/vendor}/:path"] = shareFilesFromDirectory("/Users/me/Sites/test")

server["/vendor/:path"] = shareFilesFromDirectory("/Users/me/Sites/vendor")

My regex is awful at best, so hoping someone might be able to help.

@fabianthdev
Copy link

+1 For this question. I have exactly the same problem. Did you find a way to solve this?

@jeff-h
Copy link
Author

jeff-h commented Apr 4, 2018

I actually decided to use https://github.com/BiAtoms/Http.swift which supports overlapping paths.

@kimaldis
Copy link

Oddly enough, I'm trying to do exactly the same thing. No thoughts yet?

@Vkt0r
Copy link
Member

Vkt0r commented May 1, 2019

The issue with the overlapping paths in the routes was solved in #382. Feel free to open in case it wasn't solved for you.

@Vkt0r Vkt0r closed this as completed May 1, 2019
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