mirror of
https://github.com/actix/actix-website
synced 2025-06-27 15:39:02 +02:00
moves individual examples to pub mods to force building and have less dead_code
This commit is contained in:
@ -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));
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -11,4 +11,4 @@
|
||||
// ))))))
|
||||
// }
|
||||
// </chunked>
|
||||
fn main() {}
|
||||
pub fn main() {}
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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>
|
||||
|
@ -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));
|
||||
}
|
||||
|
Reference in New Issue
Block a user