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

Dynamic segments in namespaces include namespace #86

Closed
kivikakk opened this issue Dec 31, 2016 · 2 comments
Closed

Dynamic segments in namespaces include namespace #86

kivikakk opened this issue Dec 31, 2016 · 2 comments
Labels
accepted An accepted request or suggestion bug Deviation from the specification or expected behavior

Comments

@kivikakk
Copy link

This is more-or-less a follow up to #41. Repeating the same example (on 0.1.2):

#[get("/sample/<path..>")]
fn stream(path: PathBuf) -> Option<NamedFile> {
    let filename = Path::new("/home/dawid/a_directory").join(path.clone());
    println!("{:?}, {:?}", filename, path);
    NamedFile::open(filename).ok()
}

This works fine now when stream is mounted at the root and I request http://localhost:8000/sample/dir/file.txt:

GET /sample/dir/file.txt:
    => Matched: GET /sample/<path..>
"/home/dawid/a_directory/dir/file.txt", "dir/file.txt"

But, if I mount stream under a segment, per:

.mount("/abc/", routes![stream])

Then I request http://localhost:8000/abc/sample/dir/file.txt, it is processed as follows:

GET /abc/sample/dir/file.txt:
    => Matched: GET /abc/sample/<path..>
"/home/dawid/a_directory/sample/dir/file.txt", "sample/dir/file.txt"

Note the sample segment has crept back in. Additional segments added to the namespace are included in the pathbuf.

@SergioBenitez
Copy link
Member

Of course. Confirmed.

@SergioBenitez SergioBenitez added accepted An accepted request or suggestion bug Deviation from the specification or expected behavior labels Dec 31, 2016
@kivikakk
Copy link
Author

Great! Thank you very much. 🙇‍♀️

SergioBenitez added a commit that referenced this issue Apr 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted An accepted request or suggestion bug Deviation from the specification or expected behavior
Projects
None yet
Development

No branches or pull requests

2 participants