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 route catch-all wildcards #178

Closed
sean-lynch opened this issue Jun 27, 2011 · 3 comments
Closed

Support route catch-all wildcards #178

sean-lynch opened this issue Jun 27, 2011 · 3 comments

Comments

@sean-lynch
Copy link

The current route wildcard system is great for catching parameters, but doesn't work for catch alls.

For example, I want to use catch alls to enable API versioning and uniformly handle old versions of the API

GET /api/1/contacts
POST /api/1/contacts
GET /api/1/contacts/:id
PUT /api/1/contacts/:id
DELETE /api/1/contacts/:id

If I increment the active version of the API to 2, I want to uniformly handle the old version of the API with a handler that instructs the user to update their client. I'd like to do this by specifying

@route('/api/1/*')
def deprecation_notice() :
return "Update your client"

@defnull
Copy link
Member

defnull commented Jun 27, 2011

@route('/api/1/:#.*#')
def deprecation_notice() :
    return "Update your client"

@sean-lynch
Copy link
Author

Ahh, my mistake. I thought the regex was limited to sections between / separators. Thanks!

@ghost
Copy link

ghost commented Nov 17, 2012

Here's the version for the new route syntax:
@bottle.route('/<:re:.*>', method='OPTIONS')
def options():
return 'OPTIONS'

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

2 participants