mirror of
https://github.com/rwf2/Rocket.git
synced 2024-12-31 23:02:37 +00:00
5d9035ddc1
In brief, this commit: * Updates to the latest upstream 'cookie', fixing a memory leak. * Make changes to 'CookieJar' observable only through 'pending()'. * Deprecates 'Client::new()' in favor of 'Client::tracked()'. * Makes 'dispatch()' on tracked 'Client's synchronize on cookies. * Makes 'Client::untracked()' actually untracked. This commit updates to the latest 'cookie' which removes support for 'Sync' cookie jars. Instead of relying on 'cookie', this commit implements an op-log based 'CookieJar' which internally keeps track of changes. The API is such that changes are only observable through specialized '_pending()' methods.
34 lines
942 B
Rust
34 lines
942 B
Rust
#[macro_use] extern crate rocket;
|
|
|
|
use std::path::{Path, PathBuf};
|
|
use rocket::http::ext::Normalize;
|
|
use rocket::Route;
|
|
|
|
#[get("/<path..>")]
|
|
fn files(route: &Route, path: PathBuf) -> String {
|
|
Path::new(route.base()).join(path).normalized_str().to_string()
|
|
}
|
|
|
|
mod route_guard_tests {
|
|
use super::*;
|
|
use rocket::local::blocking::Client;
|
|
|
|
fn assert_path(client: &Client, path: &str) {
|
|
let res = client.get(path).dispatch();
|
|
assert_eq!(res.into_string(), Some(path.into()));
|
|
}
|
|
|
|
#[test]
|
|
fn check_mount_path() {
|
|
let rocket = rocket::ignite()
|
|
.mount("/first", routes![files])
|
|
.mount("/second", routes![files]);
|
|
|
|
let client = Client::tracked(rocket).unwrap();
|
|
assert_path(&client, "/first/some/path");
|
|
assert_path(&client, "/second/some/path");
|
|
assert_path(&client, "/first/second/b/c");
|
|
assert_path(&client, "/second/a/b/c");
|
|
}
|
|
}
|