mirror of
https://github.com/actix/examples
synced 2025-06-29 02:10:36 +02:00
added async_ex2
This commit is contained in:
3
async_ex2/src/handlers/mod.rs
Normal file
3
async_ex2/src/handlers/mod.rs
Normal file
@ -0,0 +1,3 @@
|
||||
pub mod products;
|
||||
pub mod parts;
|
||||
|
26
async_ex2/src/handlers/parts.rs
Normal file
26
async_ex2/src/handlers/parts.rs
Normal file
@ -0,0 +1,26 @@
|
||||
use actix_multipart::{Field, Item, Multipart, MultipartError};
|
||||
use actix_web::{HttpResponse, web, error, Error};
|
||||
use futures::{future::{ok as fut_ok, err as fut_err, Either}, Future, Stream};
|
||||
|
||||
use crate::common::{Part, Product};
|
||||
|
||||
|
||||
pub fn get_parts(query: web::Query<Option<Part>>)
|
||||
-> impl Future<Item = HttpResponse, Error = Error> {
|
||||
fut_ok(HttpResponse::Ok().finish())
|
||||
}
|
||||
|
||||
pub fn add_part(new_part: web::Json<Product>)
|
||||
-> impl Future<Item = HttpResponse, Error = Error> {
|
||||
fut_ok(HttpResponse::Ok().finish())
|
||||
}
|
||||
|
||||
pub fn get_part_detail(id: web::Path<String>)
|
||||
-> impl Future<Item = HttpResponse, Error = Error> {
|
||||
fut_ok(HttpResponse::Ok().finish())
|
||||
}
|
||||
|
||||
pub fn remove_part(id: web::Path<String>)
|
||||
-> impl Future<Item = HttpResponse, Error = Error> {
|
||||
fut_ok(HttpResponse::Ok().finish())
|
||||
}
|
26
async_ex2/src/handlers/products.rs
Normal file
26
async_ex2/src/handlers/products.rs
Normal file
@ -0,0 +1,26 @@
|
||||
use actix_multipart::{Field, Item, Multipart, MultipartError};
|
||||
use actix_web::{HttpResponse, web, error, Error};
|
||||
use futures::{future::{ok as fut_ok, err as fut_err, Either}, Future, Stream};
|
||||
|
||||
use crate::common::{Part, Product};
|
||||
|
||||
|
||||
pub fn get_products(query: web::Query<Option<Part>>)
|
||||
-> impl Future<Item = HttpResponse, Error = Error> {
|
||||
fut_ok(HttpResponse::Ok().finish())
|
||||
}
|
||||
|
||||
pub fn add_product(new_product: web::Json<Product>)
|
||||
-> impl Future<Item = HttpResponse, Error = Error> {
|
||||
fut_ok(HttpResponse::Ok().finish())
|
||||
}
|
||||
|
||||
pub fn get_product_detail(id: web::Path<String>)
|
||||
-> impl Future<Item = HttpResponse, Error = Error> {
|
||||
fut_ok(HttpResponse::Ok().finish())
|
||||
}
|
||||
|
||||
pub fn remove_product(id: web::Path<String>)
|
||||
-> impl Future<Item = HttpResponse, Error = Error> {
|
||||
fut_ok(HttpResponse::Ok().finish())
|
||||
}
|
Reference in New Issue
Block a user