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:
@ -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| {
|
||||
|
@ -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;
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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) => {
|
||||
|
@ -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| {
|
||||
|
@ -19,4 +19,4 @@
|
||||
// .responder()
|
||||
// }
|
||||
// </urlencoded>
|
||||
fn main() {}
|
||||
pub fn main() {}
|
||||
|
Reference in New Issue
Block a user