1
0
mirror of https://github.com/actix/actix-website synced 2025-06-27 07:29:02 +02:00

Final fixes before requesting review.

This commit is contained in:
Cameron Dershem
2019-06-28 13:31:30 -04:00
parent cbf046b1f0
commit 5133ab874d
40 changed files with 116 additions and 81 deletions

View File

@ -1,5 +1,5 @@
// <form>
use actix_web::{web, App, HttpServer, Result};
use actix_web::{web, Result};
use serde::Deserialize;
#[derive(Deserialize)]
@ -16,6 +16,8 @@ fn index(form: web::Form<FormData>) -> Result<String> {
// </form>
pub fn main() {
use actix_web::{App, HttpServer};
HttpServer::new(|| App::new().route("/", web::post().to(index)))
.bind("127.0.0.1:8088")
.unwrap()

View File

@ -1,5 +1,5 @@
// <json-one>
use actix_web::{web, App, HttpServer, Result};
use actix_web::{web, Result};
use serde::Deserialize;
#[derive(Deserialize)]
@ -14,6 +14,8 @@ fn index(info: web::Json<Info>) -> Result<String> {
// </json-one>
pub fn main() {
use actix_web::{App, HttpServer};
HttpServer::new(|| App::new().route("/", web::post().to(index)))
.bind("127.0.0.1:8088")
.unwrap()

View File

@ -1,5 +1,5 @@
// <json-two>
use actix_web::{error, web, App, FromRequest, HttpResponse, HttpServer, Responder};
use actix_web::{error, web, FromRequest, HttpResponse, Responder};
use serde::Deserialize;
#[derive(Deserialize)]
@ -13,6 +13,8 @@ fn index(info: web::Json<Info>) -> impl Responder {
}
pub fn main() {
use actix_web::{App, HttpServer};
HttpServer::new(|| {
App::new().service(
web::resource("/")

View File

@ -1,5 +1,5 @@
// <multi>
use actix_web::{web, App, HttpServer};
use actix_web::web;
use serde::Deserialize;
#[derive(Deserialize)]
@ -15,6 +15,8 @@ fn index((path, query): (web::Path<(u32, String)>, web::Query<Info>)) -> String
}
pub fn main() {
use actix_web::{App, HttpServer};
HttpServer::new(|| {
App::new().route(
"/users/{userid}/{friend}", // <- define path parameters

View File

@ -1,5 +1,5 @@
// <path-one>
use actix_web::{web, App, HttpServer, Result};
use actix_web::{web, Result};
/// extract path info from "/users/{userid}/{friend}" url
/// {userid} - - deserializes to a u32
@ -9,6 +9,8 @@ fn index(info: web::Path<(u32, String)>) -> Result<String> {
}
pub fn main() {
use actix_web::{App, HttpServer};
HttpServer::new(|| {
App::new().route(
"/users/{userid}/{friend}", // <- define path parameters

View File

@ -1,4 +1,4 @@
use actix_web::{web, App, HttpRequest, HttpServer, Result};
use actix_web::{web, HttpRequest, Result};
// <path-three>
fn index(req: HttpRequest) -> Result<String> {
@ -9,6 +9,8 @@ fn index(req: HttpRequest) -> Result<String> {
}
pub fn main() {
use actix_web::{App, HttpServer};
HttpServer::new(|| {
App::new().route(
"/users/{userid}/{friend}", // <- define path parameters

View File

@ -1,5 +1,5 @@
// <path-two>
use actix_web::{web, App, HttpServer, Result};
use actix_web::{web, Result};
use serde::Deserialize;
#[derive(Deserialize)]
@ -14,6 +14,8 @@ fn index(info: web::Path<Info>) -> Result<String> {
}
pub fn main() {
use actix_web::{App, HttpServer};
HttpServer::new(|| {
App::new().route(
"/users/{userid}/{friend}", // <- define path parameters

View File

@ -1,5 +1,5 @@
// <query>
use actix_web::{web, App, HttpServer};
use actix_web::web;
use serde::Deserialize;
#[derive(Deserialize)]
@ -14,6 +14,8 @@ fn index(info: web::Query<Info>) -> String {
// </query>
pub fn main() {
use actix_web::{App, HttpServer};
HttpServer::new(|| App::new().route("/", web::get().to(index)))
.bind("127.0.0.1:8088")
.unwrap()