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 (<name..>) not behaving as expected #41

Closed
dawid2193487 opened this issue Dec 24, 2016 · 2 comments
Closed

Dynamic segments (<name..>) not behaving as expected #41

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

Comments

@dawid2193487
Copy link

I wrote a view like this

#[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()
}

I would expect path to be just the part of URL after /sample/, eg. localhost:8000/sample/dir/file.txt would make path be dir/file.txt, however, path becomes the whole URL after the hostname, in this example sample/dir/file.txt

🔧  Configured for development.
    => listening: localhost:8000
    => logging: Normal
🛰  Mounting '/':
    => GET /
    => GET /sample/<path..>
🚀  Rocket has launched from http://localhost:8000...
GET /sample/dir/file.txt:
    => Matched: GET /sample/<path..>
"/home/dawid/a_directory/sample/dir/file.txt", "sample/dir/file.txt"
    => Warning: Response was `None`.
    => Outcome: Failure
    => Warning: Responding with 404 Not Found catcher.
    => Response succeeded.

@SergioBenitez
Copy link
Member

SergioBenitez commented Dec 24, 2016

Just confirmed this. Tests and a fix is forthcoming.

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

Thanks so much for the bug report, by the way! 🚀

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