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 requirements to be specified on Mapper.resource #57

Merged
merged 1 commit into from
Jan 16, 2016
Merged

allow requirements to be specified on Mapper.resource #57

merged 1 commit into from
Jan 16, 2016

Commits on Jan 13, 2016

  1. Add support for requirements to mapper.resource

    This adds support for ``requirements`` option to mapper.resource,
    which makes it possible to restrict matching in urls (most often
    useful for capturing variables with path_prefix).
    
    In OpenStack Nova we've used the prefix_path on Mapper.resource to
    specify additional variables we want to capture (specifically
    {project_id}). Project_id is a uuid. When trying to restrict
    project_id to only valid uuid format a couple of issues were exposed.
    
     - #1 '/{project_id:[a-f0-9]{32}}/...' builds an incorrect regex
        because of the nested {}
    
     - #2 the preferred method that works on connect() to pass
        requirements doesn't work here (requirements are reset to only an
        id match)
    
    That leaves us with having to build a custom project_id match with 32
    [a-f0-9] strings appended for every resource added to get the support
    we need without effectively vendoring our own version of Mapper.resource.
    
    This small change to allow requirements to pass through would make it
    possible to get this tighter validation with much smaller regexes.
    sdague committed Jan 13, 2016
    Configuration menu
    Copy the full SHA
    3c24bc4 View commit details
    Browse the repository at this point in the history