35 lines
842 B
Rust
35 lines
842 B
Rust
extern crate actix_web;
|
|
extern crate diesel;
|
|
use std::{io};
|
|
|
|
|
|
use actix_web::{middleware, App, HttpServer};
|
|
use diesel::r2d2::{ConnectionManager, Pool, PooledConnection};
|
|
use diesel::PgConnection;
|
|
|
|
mod constants;
|
|
mod loota;
|
|
mod models;
|
|
mod schema;
|
|
mod connection;
|
|
|
|
pub type DBPool = Pool<ConnectionManager<PgConnection>>;
|
|
pub type DBPooledConnection = PooledConnection<ConnectionManager<PgConnection>>;
|
|
|
|
|
|
#[actix_rt::main]
|
|
async fn main() -> io::Result<()> {
|
|
env_logger::init();
|
|
|
|
HttpServer::new(|| {
|
|
App::new()
|
|
// enable logger - always register actix-web Logger middleware last
|
|
.wrap(middleware::Logger::default())
|
|
// register HTTP requests handlers
|
|
.service(loota::get)
|
|
.service(loota::update)
|
|
})
|
|
.bind("0.0.0.0:9090")?
|
|
.run()
|
|
.await
|
|
} |