1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-06-02 13:29:24 +00: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.
///
/// ## Examples
/// ```
/// use actix_web::{post, web};
/// use serde::Deserialize;
@ -46,20 +47,18 @@ use crate::{
///
/// // This handler is only called if:
/// // - 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("/")]
/// async fn index(form: web::Form<Info>) -> String {
/// async fn index(web::Form(form): web::Form<Info>) -> String {
/// format!("Welcome {}!", form.name)
/// }
/// ```
///
/// # Responder
/// The `Form` type also allows you to create URL encoded responses:
/// simply return a value of type Form<T> where T is the type to be URL encoded.
/// The type must implement [`serde::Serialize`].
///
/// Responses use
/// The `Form` type also allows you to create URL encoded responses by returning a value of type
/// `Form<T>` where `T` is the type to be URL encoded, as long as `T` implements [`Serialize`].
///
/// ## Examples
/// ```
/// use actix_web::{get, web};
/// use serde::Serialize;
@ -77,7 +76,7 @@ use crate::{
/// #[get("/")]
/// async fn index() -> web::Form<SomeForm> {
/// web::Form(SomeForm {
/// name: "actix".into(),
/// name: "actix".to_owned(),
/// age: 123
/// })
/// }