mirror of
https://github.com/actix/examples
synced 2025-06-28 18:00:37 +02:00
convert more examples
This commit is contained in:
@ -1,16 +1,16 @@
|
||||
[package]
|
||||
name = "actix-web-cors"
|
||||
version = "0.1.0"
|
||||
version = "1.0.0"
|
||||
authors = ["krircc <krircc@aliyun.com>"]
|
||||
workspace = "../../"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
actix-web = "1.0.0"
|
||||
actix-cors = "0.1.0"
|
||||
actix-rt = "1.0.0"
|
||||
actix-web = "2.0.0-alpha.6"
|
||||
actix-cors = "0.2.0-alpha.3"
|
||||
serde = "1.0"
|
||||
serde_derive = "1.0"
|
||||
serde_json = "1.0"
|
||||
dotenv = "0.10"
|
||||
env_logger = "0.6"
|
||||
futures = "0.1"
|
||||
futures = "0.3"
|
||||
|
@ -6,7 +6,8 @@ use actix_web::{http::header, middleware::Logger, web, App, HttpServer};
|
||||
|
||||
mod user;
|
||||
|
||||
fn main() -> std::io::Result<()> {
|
||||
#[actix_rt::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
std::env::set_var("RUST_LOG", "actix_web=info");
|
||||
env_logger::init();
|
||||
|
||||
@ -18,11 +19,13 @@ fn main() -> std::io::Result<()> {
|
||||
.allowed_methods(vec!["GET", "POST"])
|
||||
.allowed_headers(vec![header::AUTHORIZATION, header::ACCEPT])
|
||||
.allowed_header(header::CONTENT_TYPE)
|
||||
.max_age(3600),
|
||||
.max_age(3600)
|
||||
.finish(),
|
||||
)
|
||||
.wrap(Logger::default())
|
||||
.service(web::resource("/user/info").route(web::post().to(user::info)))
|
||||
})
|
||||
.bind("127.0.0.1:8000")?
|
||||
.run()
|
||||
.start()
|
||||
.await
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ pub struct Info {
|
||||
confirm_password: String,
|
||||
}
|
||||
|
||||
pub fn info(info: web::Json<Info>) -> web::Json<Info> {
|
||||
pub async fn info(info: web::Json<Info>) -> web::Json<Info> {
|
||||
println!("=========={:?}=========", info);
|
||||
web::Json(Info {
|
||||
username: info.username.clone(),
|
||||
|
Reference in New Issue
Block a user