2018-05-08 20:08:43 +02:00
|
|
|
#[macro_use]
|
|
|
|
extern crate serde_derive;
|
2018-04-13 03:18:42 +02:00
|
|
|
|
2018-05-21 06:03:29 +02:00
|
|
|
use actix_web::{
|
2019-03-29 21:43:03 +01:00
|
|
|
http::header, middleware::cors::Cors, middleware::Logger, web, App, HttpServer,
|
2018-05-21 06:03:29 +02:00
|
|
|
};
|
2018-04-13 03:18:42 +02:00
|
|
|
|
|
|
|
mod user;
|
|
|
|
|
2019-03-29 21:43:03 +01:00
|
|
|
fn main() -> std::io::Result<()> {
|
|
|
|
std::env::set_var("RUST_LOG", "actix_web=info");
|
2018-04-13 03:18:42 +02:00
|
|
|
env_logger::init();
|
|
|
|
|
2019-03-29 21:43:03 +01:00
|
|
|
HttpServer::new(move || {
|
2018-05-08 20:08:43 +02:00
|
|
|
App::new()
|
2019-03-29 21:43:03 +01:00
|
|
|
.wrap(
|
|
|
|
Cors::new()
|
2018-05-08 20:08:43 +02:00
|
|
|
.allowed_origin("http://localhost:1234")
|
|
|
|
.allowed_methods(vec!["GET", "POST"])
|
|
|
|
.allowed_headers(vec![header::AUTHORIZATION, header::ACCEPT])
|
|
|
|
.allowed_header(header::CONTENT_TYPE)
|
2019-03-29 21:43:03 +01:00
|
|
|
.max_age(3600),
|
|
|
|
)
|
|
|
|
.wrap(Logger::default())
|
|
|
|
.service(web::resource("/user/info").route(web::post().to(user::info)))
|
2019-03-10 03:03:09 +01:00
|
|
|
})
|
2019-03-29 21:43:03 +01:00
|
|
|
.bind("127.0.0.1:8000")?
|
|
|
|
.run()
|
2018-04-13 03:18:42 +02:00
|
|
|
}
|