You've already forked AstralRinth
forked from didirus/AstralRinth
Migrate to MongoDB
This commit is contained in:
18
src/main.rs
18
src/main.rs
@@ -2,19 +2,25 @@
|
||||
extern crate serde_json;
|
||||
|
||||
#[macro_use]
|
||||
extern crate diesel;
|
||||
extern crate bson;
|
||||
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
|
||||
use actix_files as fs;
|
||||
use actix_web::{web, App, HttpServer};
|
||||
use handlebars::*;
|
||||
use actix_web::middleware::Logger;
|
||||
use env_logger::Env;
|
||||
|
||||
mod database;
|
||||
mod helpers;
|
||||
mod routes;
|
||||
mod schema;
|
||||
|
||||
#[actix_rt::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
env_logger::from_env(Env::default().default_filter_or("info")).init();
|
||||
|
||||
//Handlebars
|
||||
let mut handlebars = Handlebars::new();
|
||||
|
||||
@@ -26,13 +32,17 @@ async fn main() -> std::io::Result<()> {
|
||||
|
||||
let handlebars_ref = web::Data::new(handlebars);
|
||||
|
||||
let database = database::connect();
|
||||
routes::index_mods(database).await;
|
||||
let client = database::connect().await.unwrap();
|
||||
routes::index_mods(client.clone()).await;
|
||||
|
||||
info!("Starting Actix HTTP server!");
|
||||
//Init App
|
||||
HttpServer::new(move || {
|
||||
App::new()
|
||||
.wrap(Logger::default())
|
||||
.wrap(Logger::new("%a %{User-Agent}i"))
|
||||
.app_data(handlebars_ref.clone())
|
||||
.app_data(client.clone())
|
||||
.service(fs::Files::new("/static", "./static").show_files_listing())
|
||||
.service(routes::index_get)
|
||||
.service(routes::search_post)
|
||||
|
||||
Reference in New Issue
Block a user