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,7 +1,5 @@
// <guard>
use actix_web::{
dev::RequestHead, guard::Guard, http, web, App, HttpResponse, HttpServer,
};
use actix_web::{dev::RequestHead, guard::Guard, http, HttpResponse};
struct ContentTypeHeader;
@ -12,6 +10,8 @@ impl Guard for ContentTypeHeader {
}
pub fn main() {
use actix_web::{web, App, HttpServer};
HttpServer::new(|| {
App::new().route(
"/",

View File

@ -1,5 +1,5 @@
// <minfo>
use actix_web::{web, App, HttpRequest, Result};
use actix_web::{HttpRequest, HttpResponse, Result};
fn index(req: HttpRequest) -> Result<String> {
let v1: u8 = req.match_info().get("v1").unwrap().parse().unwrap();
@ -9,12 +9,12 @@ fn index(req: HttpRequest) -> Result<String> {
}
pub fn main() {
use actix_web::HttpServer;
use actix_web::{web, App, HttpServer};
HttpServer::new(|| {
App::new()
.route("/a/{v1}/{v2}/", web::get().to(index))
.route("", web::get().to(|| actix_web::HttpResponse::Ok()))
.route("", web::get().to(|| HttpResponse::Ok()))
})
.bind("127.0.0.1:8088")
.unwrap()

View File

@ -1,12 +1,12 @@
// <norm>
use actix_web::{middleware, web, App, HttpResponse};
use actix_web::{middleware, HttpResponse};
fn index() -> HttpResponse {
HttpResponse::Ok().body("Hello")
}
pub fn main() {
use actix_web::HttpServer;
use actix_web::{web, App, HttpServer};
HttpServer::new(|| {
App::new()

View File

@ -1,3 +1,9 @@
use actix_web::HttpResponse;
fn index() -> HttpResponse {
HttpResponse::Ok().body("Hello")
}
// <norm>
use actix_web::{http::Method, middleware, web, App, HttpServer};
@ -14,9 +20,3 @@ pub fn main() {
.unwrap();
}
// </norm>
use actix_web::HttpResponse;
fn index() -> HttpResponse {
HttpResponse::Ok().body("Hello")
}

View File

@ -1,12 +1,12 @@
// <path>
use actix_web::{web, App, Result};
use actix_web::{web, Result};
fn index(info: web::Path<(String, u32)>) -> Result<String> {
Ok(format!("Welcome {}! id: {}", info.0, info.1))
}
pub fn main() {
use actix_web::HttpServer;
use actix_web::{App, HttpServer};
HttpServer::new(|| {
App::new().route(

View File

@ -1,5 +1,5 @@
// <path>
use actix_web::{web, App, Result};
use actix_web::{web, Result};
use serde::Deserialize;
#[derive(Deserialize)]
@ -13,7 +13,7 @@ fn index(info: web::Path<Info>) -> Result<String> {
}
pub fn main() {
use actix_web::HttpServer;
use actix_web::{App, HttpServer};
HttpServer::new(|| {
App::new().route(

View File

@ -1,5 +1,5 @@
// <pbuf>
use actix_web::{web, App, HttpRequest, Result};
use actix_web::{HttpRequest, Result};
use std::path::PathBuf;
fn index(req: HttpRequest) -> Result<String> {
@ -8,7 +8,7 @@ fn index(req: HttpRequest) -> Result<String> {
}
pub fn main() {
use actix_web::HttpServer;
use actix_web::{web, App, HttpServer};
HttpServer::new(|| App::new().route(r"/a/{tail:.*}", web::get().to(index)))
.bind("127.0.0.1:8088")

View File

@ -5,8 +5,8 @@ fn show_users() -> HttpResponse {
HttpResponse::Ok().body("Show users")
}
fn user_detail(_path: web::Path<(u32,)>) -> HttpResponse {
HttpResponse::Ok().body("User detail")
fn user_detail(path: web::Path<(u32,)>) -> HttpResponse {
HttpResponse::Ok().body(format!("User detail: {}", path.0))
}
pub fn main() {

View File

@ -1,5 +1,5 @@
// <ext>
use actix_web::{web, App, HttpRequest, Responder};
use actix_web::{HttpRequest, Responder};
fn index(req: HttpRequest) -> impl Responder {
let url = req.url_for("youtube", &["oHg5SJYRHA0"]).unwrap();
@ -9,7 +9,7 @@ fn index(req: HttpRequest) -> impl Responder {
}
pub fn main() {
use actix_web::HttpServer;
use actix_web::{web, App, HttpServer};
HttpServer::new(|| {
App::new()

View File

@ -1,5 +1,5 @@
// <url>
use actix_web::{guard, http::header, web, App, HttpRequest, HttpResponse, Result};
use actix_web::{guard, http::header, HttpRequest, HttpResponse, Result};
fn index(req: HttpRequest) -> Result<HttpResponse> {
let url = req.url_for("foo", &["1", "2", "3"])?; // <- generate url for "foo" resource
@ -10,7 +10,7 @@ fn index(req: HttpRequest) -> Result<HttpResponse> {
}
pub fn main() {
use actix_web::HttpServer;
use actix_web::{web, App, HttpServer};
HttpServer::new(|| {
App::new()