mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-29 00:00:18 +02:00
Use impl IntoResponse less in docs (#1049)
This commit is contained in:
@@ -50,7 +50,7 @@ pub use cookie_lib::Key;
|
||||
/// async fn create_session(
|
||||
/// TypedHeader(auth): TypedHeader<Authorization<Bearer>>,
|
||||
/// jar: CookieJar,
|
||||
/// ) -> impl IntoResponse {
|
||||
/// ) -> Result<(CookieJar, Redirect), StatusCode> {
|
||||
/// if let Some(session_id) = authorize_and_create_session(auth.token()).await {
|
||||
/// Ok((
|
||||
/// // the updated jar must be returned for the changes
|
||||
@@ -63,7 +63,7 @@ pub use cookie_lib::Key;
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// async fn me(jar: CookieJar) -> impl IntoResponse {
|
||||
/// async fn me(jar: CookieJar) -> Result<(), StatusCode> {
|
||||
/// if let Some(session_id) = jar.get("session_id") {
|
||||
/// // fetch and render user...
|
||||
/// # Ok(())
|
||||
@@ -141,7 +141,7 @@ impl CookieJar {
|
||||
/// use axum_extra::extract::cookie::{CookieJar, Cookie};
|
||||
/// use axum::response::IntoResponse;
|
||||
///
|
||||
/// async fn handle(jar: CookieJar) -> impl IntoResponse {
|
||||
/// async fn handle(jar: CookieJar) -> CookieJar {
|
||||
/// jar.remove(Cookie::named("foo"))
|
||||
/// }
|
||||
/// ```
|
||||
@@ -161,7 +161,7 @@ impl CookieJar {
|
||||
/// use axum_extra::extract::cookie::{CookieJar, Cookie};
|
||||
/// use axum::response::IntoResponse;
|
||||
///
|
||||
/// async fn handle(jar: CookieJar) -> impl IntoResponse {
|
||||
/// async fn handle(jar: CookieJar) -> CookieJar {
|
||||
/// jar.add(Cookie::new("foo", "bar"))
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@@ -33,12 +33,12 @@ use std::{convert::Infallible, fmt, marker::PhantomData};
|
||||
///
|
||||
/// async fn set_secret(
|
||||
/// jar: PrivateCookieJar,
|
||||
/// ) -> impl IntoResponse {
|
||||
/// ) -> (PrivateCookieJar, Redirect) {
|
||||
/// let updated_jar = jar.add(Cookie::new("secret", "secret-data"));
|
||||
/// (updated_jar, Redirect::to("/get"))
|
||||
/// }
|
||||
///
|
||||
/// async fn get_secret(jar: PrivateCookieJar) -> impl IntoResponse {
|
||||
/// async fn get_secret(jar: PrivateCookieJar) {
|
||||
/// if let Some(data) = jar.get("secret") {
|
||||
/// // ...
|
||||
/// }
|
||||
@@ -129,7 +129,7 @@ impl<K> PrivateCookieJar<K> {
|
||||
/// use axum_extra::extract::cookie::{PrivateCookieJar, Cookie};
|
||||
/// use axum::response::IntoResponse;
|
||||
///
|
||||
/// async fn handle(jar: PrivateCookieJar) -> impl IntoResponse {
|
||||
/// async fn handle(jar: PrivateCookieJar) -> PrivateCookieJar {
|
||||
/// jar.remove(Cookie::named("foo"))
|
||||
/// }
|
||||
/// ```
|
||||
@@ -149,7 +149,7 @@ impl<K> PrivateCookieJar<K> {
|
||||
/// use axum_extra::extract::cookie::{PrivateCookieJar, Cookie};
|
||||
/// use axum::response::IntoResponse;
|
||||
///
|
||||
/// async fn handle(jar: PrivateCookieJar) -> impl IntoResponse {
|
||||
/// async fn handle(jar: PrivateCookieJar) -> PrivateCookieJar {
|
||||
/// jar.add(Cookie::new("foo", "bar"))
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@@ -35,7 +35,7 @@ use std::{convert::Infallible, fmt, marker::PhantomData};
|
||||
/// async fn create_session(
|
||||
/// TypedHeader(auth): TypedHeader<Authorization<Bearer>>,
|
||||
/// jar: SignedCookieJar,
|
||||
/// ) -> impl IntoResponse {
|
||||
/// ) -> Result<(SignedCookieJar, Redirect), StatusCode> {
|
||||
/// if let Some(session_id) = authorize_and_create_session(auth.token()).await {
|
||||
/// Ok((
|
||||
/// // the updated jar must be returned for the changes
|
||||
@@ -48,7 +48,7 @@ use std::{convert::Infallible, fmt, marker::PhantomData};
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// async fn me(jar: SignedCookieJar) -> impl IntoResponse {
|
||||
/// async fn me(jar: SignedCookieJar) -> Result<(), StatusCode> {
|
||||
/// if let Some(session_id) = jar.get("session_id") {
|
||||
/// // fetch and render user...
|
||||
/// # Ok(())
|
||||
@@ -148,7 +148,7 @@ impl<K> SignedCookieJar<K> {
|
||||
/// use axum_extra::extract::cookie::{SignedCookieJar, Cookie};
|
||||
/// use axum::response::IntoResponse;
|
||||
///
|
||||
/// async fn handle(jar: SignedCookieJar) -> impl IntoResponse {
|
||||
/// async fn handle(jar: SignedCookieJar) -> SignedCookieJar {
|
||||
/// jar.remove(Cookie::named("foo"))
|
||||
/// }
|
||||
/// ```
|
||||
@@ -168,7 +168,7 @@ impl<K> SignedCookieJar<K> {
|
||||
/// use axum_extra::extract::cookie::{SignedCookieJar, Cookie};
|
||||
/// use axum::response::IntoResponse;
|
||||
///
|
||||
/// async fn handle(jar: SignedCookieJar) -> impl IntoResponse {
|
||||
/// async fn handle(jar: SignedCookieJar) -> SignedCookieJar {
|
||||
/// jar.add(Cookie::new("foo", "bar"))
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
Reference in New Issue
Block a user