1
0
mirror of https://github.com/actix/examples synced 2024-12-01 01:24:35 +01:00
examples/graphql-demo/src/main.rs

31 lines
697 B
Rust
Raw Normal View History

#[macro_use]
extern crate juniper;
extern crate r2d2;
extern crate r2d2_mysql;
extern crate serde_json;
use actix_web::{App, HttpServer, middleware, web};
use crate::db::get_db_pool;
use crate::handlers::{register};
mod handlers;
mod schemas;
mod db;
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(|| "404"))
})
.bind("127.0.0.1:8080")?
.run()
}