1
0
mirror of https://github.com/actix/examples synced 2024-12-01 01:24:35 +01:00
examples/juniper-advanced/src/main.rs
2020-05-19 14:23:28 +09:00

34 lines
733 B
Rust

#[macro_use]
extern crate juniper;
extern crate r2d2;
extern crate r2d2_mysql;
extern crate serde_json;
use actix_web::{middleware, web, App, HttpServer};
use crate::db::get_db_pool;
use crate::handlers::register;
mod db;
mod handlers;
mod schemas;
#[actix_rt::main]
async fn main() -> std::io::Result<()> {
dotenv::dotenv().ok();
std::env::set_var("RUST_LOG", "actix_web=info,info");
env_logger::init();
let pool = get_db_pool();
HttpServer::new(move || {
App::new()
.data(pool.clone())
.wrap(middleware::Logger::default())
.configure(register)
.default_service(web::to(|| async { "404" }))
})
.bind("127.0.0.1:8080")?
.run()
.await
}