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

moves individual examples to pub mods to force building and have less dead_code

This commit is contained in:
Cameron Dershem
2019-06-19 00:20:50 -04:00
parent a3cb721ed3
commit 4f9bd8b724
49 changed files with 226 additions and 191 deletions

View File

@ -3,12 +3,12 @@ use actix_web::{
http::ContentEncoding, middleware, web, App, HttpRequest, HttpResponse,
};
fn index(req: HttpRequest) -> HttpResponse {
fn index(_req: HttpRequest) -> HttpResponse {
HttpResponse::Ok().body("data")
}
fn main() {
let app = App::new()
pub fn main() {
App::new()
// v- disable compression for all routes
.wrap(middleware::Compress::new(ContentEncoding::Identity))
.route("/", web::get().to(index));

View File

@ -3,11 +3,14 @@ use actix_web::{
http::ContentEncoding, middleware::BodyEncoding, HttpRequest, HttpResponse,
};
fn index_br(req: HttpRequest) -> HttpResponse {
fn index_br(_req: HttpRequest) -> HttpResponse {
HttpResponse::Ok()
.encoding(ContentEncoding::Br)
.body("data")
}
// </brotli>
fn main() {}
use actix_web::{web, App};
pub fn main() {
App::new().route("/", web::get().to(index_br));
}

View File

@ -11,4 +11,4 @@
// ))))))
// }
// </chunked>
fn main() {}
pub fn main() {}

View File

@ -3,10 +3,15 @@ use actix_web::{
http::ContentEncoding, middleware::BodyEncoding, HttpRequest, HttpResponse,
};
fn index(req: HttpRequest) -> HttpResponse {
fn index(_req: HttpRequest) -> HttpResponse {
HttpResponse::Ok()
// v- disable compression
.encoding(ContentEncoding::Identity)
.body("data")
}
// </identity>
use actix_web::{web, App};
pub fn main() {
App::new().route("/", web::get().to(index));
}

View File

@ -16,3 +16,8 @@ pub fn index(_req: HttpRequest) -> HttpResponse {
.body(HELLO_WORLD)
}
// </identity-two>
use actix_web::{web, App};
pub fn main() {
App::new().route("/", web::get().to(index));
}

View File

@ -13,7 +13,7 @@ fn index(req: HttpRequest) -> Result<web::Json<MyObj>> {
}))
}
fn main() {
pub fn main() {
App::new().route(r"/a/{name}", web::get().to(index));
}
// </json-resp>

View File

@ -1,9 +1,9 @@
mod auto;
mod brotli;
mod chunked;
mod identity;
mod identity_two;
mod json_resp;
pub mod auto;
pub mod brotli;
pub mod chunked;
pub mod identity;
pub mod identity_two;
pub mod json_resp;
// <builder>
use actix_web::{
http::ContentEncoding, middleware::BodyEncoding, HttpRequest, HttpResponse,
@ -18,4 +18,7 @@ fn index(_req: HttpRequest) -> HttpResponse {
}
// </builder>
fn main() {}
use actix_web::{web, App};
pub fn main() {
App::new().route("/", web::get().to(index));
}