mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-28 09:42:40 +01:00
update Path and Query doc strings
This commit is contained in:
parent
9f5a91ae3c
commit
36161aba99
@ -29,18 +29,21 @@ pub trait HttpRequestExtractor<T, S>: Sized where T: DeserializeOwned, S: 'stati
|
|||||||
/// use actix_web::*;
|
/// use actix_web::*;
|
||||||
/// use actix_web::Path;
|
/// use actix_web::Path;
|
||||||
///
|
///
|
||||||
|
/// /// Application state
|
||||||
|
/// struct State {}
|
||||||
|
///
|
||||||
/// #[derive(Deserialize)]
|
/// #[derive(Deserialize)]
|
||||||
/// struct Info {
|
/// struct Info {
|
||||||
/// username: String,
|
/// username: String,
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// /// extract path info using serde
|
/// /// extract path info using serde
|
||||||
/// fn index(info: Path<Info>) -> Result<String> {
|
/// fn index(info: Path<Info, State>) -> Result<String> {
|
||||||
/// Ok(format!("Welcome {}!", info.username))
|
/// Ok(format!("Welcome {}!", info.username))
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// fn main() {
|
/// fn main() {
|
||||||
/// let app = Application::new().resource(
|
/// let app = Application::with_state(State{}).resource(
|
||||||
/// "/{username}/index.html", // <- define path parameters
|
/// "/{username}/index.html", // <- define path parameters
|
||||||
/// |r| r.method(Method::GET).with(index)); // <- use `with` extractor
|
/// |r| r.method(Method::GET).with(index)); // <- use `with` extractor
|
||||||
/// }
|
/// }
|
||||||
@ -113,6 +116,9 @@ impl<T, S> HttpRequestExtractor<T, S> for Path<T, S>
|
|||||||
/// use actix_web::*;
|
/// use actix_web::*;
|
||||||
/// use actix_web::Query;
|
/// use actix_web::Query;
|
||||||
///
|
///
|
||||||
|
/// /// Application state
|
||||||
|
/// struct State {}
|
||||||
|
///
|
||||||
/// #[derive(Deserialize)]
|
/// #[derive(Deserialize)]
|
||||||
/// struct Info {
|
/// struct Info {
|
||||||
/// username: String,
|
/// username: String,
|
||||||
@ -120,12 +126,12 @@ impl<T, S> HttpRequestExtractor<T, S> for Path<T, S>
|
|||||||
///
|
///
|
||||||
/// // use `with` extractor for query info
|
/// // use `with` extractor for query info
|
||||||
/// // this handler get called only if request's query contains `username` field
|
/// // this handler get called only if request's query contains `username` field
|
||||||
/// fn index(info: Query<Info>) -> Result<String> {
|
/// fn index(info: Query<Info, State>) -> Result<String> {
|
||||||
/// Ok(format!("Welcome {}!", info.username))
|
/// Ok(format!("Welcome {}!", info.username))
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// fn main() {
|
/// fn main() {
|
||||||
/// let app = Application::new().resource(
|
/// let app = Application::with_state(State{}).resource(
|
||||||
/// "/index.html",
|
/// "/index.html",
|
||||||
/// |r| r.method(Method::GET).with(index)); // <- use `with` extractor
|
/// |r| r.method(Method::GET).with(index)); // <- use `with` extractor
|
||||||
/// }
|
/// }
|
||||||
|
Loading…
Reference in New Issue
Block a user