1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-02-07 13:54:24 +01:00

tweak form docs

This commit is contained in:
Rob Ede 2022-11-25 21:38:36 +00:00
parent d708a4de6d
commit e7c34f2e45
No known key found for this signature in database
GPG Key ID: 97C636207D3EF933

View File

@ -35,6 +35,7 @@ use crate::{
/// ///
/// Use [`FormConfig`] to configure extraction options. /// Use [`FormConfig`] to configure extraction options.
/// ///
/// ## Examples
/// ``` /// ```
/// use actix_web::{post, web}; /// use actix_web::{post, web};
/// use serde::Deserialize; /// use serde::Deserialize;
@ -46,20 +47,18 @@ use crate::{
/// ///
/// // This handler is only called if: /// // This handler is only called if:
/// // - request headers declare the content type as `application/x-www-form-urlencoded` /// // - request headers declare the content type as `application/x-www-form-urlencoded`
/// // - request payload is deserialized into a `Info` struct from the URL encoded format /// // - request payload deserializes into an `Info` struct from the URL encoded format
/// #[post("/")] /// #[post("/")]
/// async fn index(form: web::Form<Info>) -> String { /// async fn index(web::Form(form): web::Form<Info>) -> String {
/// format!("Welcome {}!", form.name) /// format!("Welcome {}!", form.name)
/// } /// }
/// ``` /// ```
/// ///
/// # Responder /// # Responder
/// The `Form` type also allows you to create URL encoded responses: /// The `Form` type also allows you to create URL encoded responses by returning a value of type
/// simply return a value of type Form<T> where T is the type to be URL encoded. /// `Form<T>` where `T` is the type to be URL encoded, as long as `T` implements [`Serialize`].
/// The type must implement [`serde::Serialize`].
///
/// Responses use
/// ///
/// ## Examples
/// ``` /// ```
/// use actix_web::{get, web}; /// use actix_web::{get, web};
/// use serde::Serialize; /// use serde::Serialize;
@ -77,7 +76,7 @@ use crate::{
/// #[get("/")] /// #[get("/")]
/// async fn index() -> web::Form<SomeForm> { /// async fn index() -> web::Form<SomeForm> {
/// web::Form(SomeForm { /// web::Form(SomeForm {
/// name: "actix".into(), /// name: "actix".to_owned(),
/// age: 123 /// age: 123
/// }) /// })
/// } /// }