mirror of https://github.com/fafhrd91/actix-web
cargo fmt
This commit is contained in:
parent
7f1f131d44
commit
da9d93669f
|
@ -99,8 +99,8 @@ impl<T: str::FromStr> str::FromStr for QualityItem<T> {
|
||||||
let mut raw_item = q_item_str;
|
let mut raw_item = q_item_str;
|
||||||
let mut quality = Quality::MAX;
|
let mut quality = Quality::MAX;
|
||||||
|
|
||||||
let parts = str_rsplit_once(q_item_str, ';')
|
let parts =
|
||||||
.map(|(item, q_attr)| (item.trim(), q_attr.trim()));
|
str_rsplit_once(q_item_str, ';').map(|(item, q_attr)| (item.trim(), q_attr.trim()));
|
||||||
|
|
||||||
if let Some((val, q_attr)) = parts {
|
if let Some((val, q_attr)) = parts {
|
||||||
// example for item with q-factor:
|
// example for item with q-factor:
|
||||||
|
|
|
@ -123,7 +123,11 @@ macro_rules! error_helper {
|
||||||
error_helper!(
|
error_helper!(
|
||||||
$name,
|
$name,
|
||||||
$status,
|
$status,
|
||||||
concat!("Helper function that wraps any error and generates a `", stringify!($status), "` response.")
|
concat!(
|
||||||
|
"Helper function that wraps any error and generates a `",
|
||||||
|
stringify!($status),
|
||||||
|
"` response."
|
||||||
|
)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
($name:ident, $status:ident, $doc:expr) => {
|
($name:ident, $status:ident, $doc:expr) => {
|
||||||
|
|
12
src/guard.rs
12
src/guard.rs
|
@ -295,8 +295,16 @@ macro_rules! method_guard {
|
||||||
method_guard!(
|
method_guard!(
|
||||||
$method_fn,
|
$method_fn,
|
||||||
$method_const,
|
$method_const,
|
||||||
concat!("Creates a guard that matches the `", stringify!($method_const), "` request method."),
|
concat!(
|
||||||
concat!("The route in this example will only respond to `", stringify!($method_const), "` requests."),
|
"Creates a guard that matches the `",
|
||||||
|
stringify!($method_const),
|
||||||
|
"` request method."
|
||||||
|
),
|
||||||
|
concat!(
|
||||||
|
"The route in this example will only respond to `",
|
||||||
|
stringify!($method_const),
|
||||||
|
"` requests."
|
||||||
|
),
|
||||||
concat!(" .guard(guard::", stringify!($method_fn), "())")
|
concat!(" .guard(guard::", stringify!($method_fn), "())")
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
21
src/web.rs
21
src/web.rs
|
@ -83,7 +83,6 @@ pub fn route() -> Route {
|
||||||
Route::new()
|
Route::new()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
macro_rules! method_route {
|
macro_rules! method_route {
|
||||||
// Workaround for 1.52.0 compat. It's not great but any use of `concat!` must be done prior
|
// Workaround for 1.52.0 compat. It's not great but any use of `concat!` must be done prior
|
||||||
// to insertion in a doc comment.
|
// to insertion in a doc comment.
|
||||||
|
@ -91,9 +90,21 @@ macro_rules! method_route {
|
||||||
method_route!(
|
method_route!(
|
||||||
$method_fn,
|
$method_fn,
|
||||||
$method_const,
|
$method_const,
|
||||||
concat!(" Creates a new route with `", stringify!($method_const), "` method guard."),
|
concat!(
|
||||||
concat!(" In this example, one `", stringify!($method_const), " /{project_id}` route is set up:"),
|
" Creates a new route with `",
|
||||||
concat!(" .route(web::", stringify!($method_fn), "().to(|| HttpResponse::Ok()))")
|
stringify!($method_const),
|
||||||
|
"` method guard."
|
||||||
|
),
|
||||||
|
concat!(
|
||||||
|
" In this example, one `",
|
||||||
|
stringify!($method_const),
|
||||||
|
" /{project_id}` route is set up:"
|
||||||
|
),
|
||||||
|
concat!(
|
||||||
|
" .route(web::",
|
||||||
|
stringify!($method_fn),
|
||||||
|
"().to(|| HttpResponse::Ok()))"
|
||||||
|
)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
($method_fn:ident, $method_const:ident, $doc1:expr, $doc2:expr, $doc3:expr) => {
|
($method_fn:ident, $method_const:ident, $doc1:expr, $doc2:expr, $doc3:expr) => {
|
||||||
|
@ -113,7 +124,7 @@ macro_rules! method_route {
|
||||||
pub fn $method_fn() -> Route {
|
pub fn $method_fn() -> Route {
|
||||||
method(Method::$method_const)
|
method(Method::$method_const)
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
method_route!(get, GET);
|
method_route!(get, GET);
|
||||||
|
|
Loading…
Reference in New Issue