January 2019
Intermediate to advanced
520 pages
14h 32m
English
Other methods allow users to sign in to a microservice with the provided credentials. Look at the following signin function that processes requests that are sent to the /signin path:
fn signin((req, params): (HttpRequest<State>, Form<UserForm>)) -> FutureResponse<HttpResponse>{ let fut = post_request("http://127.0.0.1:8001/signin", params.into_inner()) .map(move |id: UserId| { req.remember(id.id); HttpResponse::build_from(&req) .status(StatusCode::FOUND) .header(header::LOCATION, "/comments.html") .finish() }); Box::new(fut)}
The function has two parameters: HttpRequest and Form. The first we need to get access to a shared State object. The second we need to extract the UserForm struct from the request body. We can also use the post_request ...
Read now
Unlock full access