1
0
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:
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

@ -9,7 +9,7 @@
// number: i32,
// }
// fn index(req: HttpRequest) -> Box<Future<Item = HttpResponse, Error = Error>> {
// pub fn index(req: HttpRequest) -> Box<Future<Item = HttpResponse, Error = Error>> {
// req.json()
// .from_err()
// .and_then(|val: MyObj| {

View File

@ -1,8 +1,8 @@
mod json_two;
mod manual;
mod multipart;
mod streaming;
mod urlencoded;
pub mod json_two;
pub mod manual;
pub mod multipart;
pub mod streaming;
pub mod urlencoded;
// <json-request>
use actix_web::{web, App, Result};
use serde::Deserialize;

View File

@ -1,5 +1,5 @@
// <json-manual>
use actix_web::{error, web, Error, HttpResponse};
use actix_web::{error, web, App, Error, HttpResponse};
use bytes::BytesMut;
use futures::{Future, Stream};
use serde::{Deserialize, Serialize};
@ -13,7 +13,7 @@ struct MyObj {
const MAX_SIZE: usize = 262_144; // max payload size is 256k
fn index_manual(
pub fn index_manual(
payload: web::Payload,
) -> impl Future<Item = HttpResponse, Error = Error> {
// payload is a stream of Bytes objects
@ -41,3 +41,7 @@ fn index_manual(
})
}
// </json-manual>
pub fn main() {
App::new().route("/", web::post().to_async(index_manual));
}

View File

@ -2,7 +2,7 @@
// use actix_web::{error, Error, HttpRequest, HttpResponse};
// use futures::Future;
// fn index(req: HttpRequest) -> Box<Future<Item = HttpResponse, Error = Error>> {
// pub fn index(req: HttpRequest) -> Box<Future<Item = HttpResponse, Error = Error>> {
// // get multipart and iterate over multipart items
// req.multipart().and_then(|item| match item {
// multipart::MultipartItem::Field(field) => {

View File

@ -2,7 +2,7 @@
// use actix_web::{error, web, Error, HttpResponse};
// use futures::{future::result, Future, Stream};
// fn index(payload: web::Payload) -> Box<Future<Item = HttpResponse, Error = Error>> {
// pub fn index(payload: web::Payload) -> Box<Future<Item = HttpResponse, Error = Error>> {
// payload
// .from_err()
// .fold((), |_, chunk| {

View File

@ -19,4 +19,4 @@
// .responder()
// }
// </urlencoded>
fn main() {}
pub fn main() {}