mirror of
https://github.com/fafhrd91/actix-web
synced 2025-01-31 11:02:08 +01:00
tweak form docs
This commit is contained in:
parent
d708a4de6d
commit
e7c34f2e45
@ -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
|
||||
/// })
|
||||
/// }
|
||||
|
Loading…
x
Reference in New Issue
Block a user