mirror of
https://github.com/actix/examples
synced 2024-12-04 10:41:56 +01:00
20 lines
469 B
Rust
20 lines
469 B
Rust
|
use actix_web::{AsyncResponder, Error, HttpMessage, HttpResponse, HttpRequest};
|
||
|
use futures::Future;
|
||
|
|
||
|
|
||
|
#[derive(Deserialize,Serialize, Debug)]
|
||
|
struct Info {
|
||
|
username: String,
|
||
|
email: String,
|
||
|
password: String,
|
||
|
confirm_password: String,
|
||
|
}
|
||
|
|
||
|
pub fn info(req: HttpRequest) -> Box<Future<Item=HttpResponse, Error=Error>> {
|
||
|
req.json()
|
||
|
.from_err()
|
||
|
.and_then(|res: Info| {
|
||
|
Ok(HttpResponse::Ok().json(res))
|
||
|
}).responder()
|
||
|
}
|