cryptgeon/src/main.rs

33 lines
1.0 KiB
Rust
Raw Normal View History

2021-05-02 12:32:03 +02:00
use actix_web::{middleware, web, App, HttpServer};
2021-05-01 12:39:40 +02:00
#[macro_use]
extern crate lazy_static;
2021-05-02 12:32:03 +02:00
mod client;
2021-05-01 12:39:40 +02:00
mod note;
2021-12-20 17:42:16 +01:00
mod size;
2021-05-02 12:32:03 +02:00
mod store;
2021-05-01 12:39:40 +02:00
#[actix_web::main]
async fn main() -> std::io::Result<()> {
2021-12-20 17:42:16 +01:00
return HttpServer::new(|| {
2021-05-01 12:39:40 +02:00
App::new()
2021-12-20 17:42:16 +01:00
// .configure(|cfg: &mut web::ServiceConfig| {
// let limit_string = std::env::var("SIZE_LIMIT").unwrap_or("0.1 KiB".to_string());
// let limit = Byte::from_str(limit_string.clone()).unwrap().get_bytes() as usize;
// println!("SIZE_LIMIT: {}, {}", limit_string, limit);
// let config = web::JsonConfig::default().limit(limit);
// cfg.data(config);
// })
2021-05-01 12:39:40 +02:00
.wrap(middleware::Compress::default())
.wrap(middleware::DefaultHeaders::default())
2021-12-20 17:42:16 +01:00
.configure(size::init)
2021-05-01 12:39:40 +02:00
.configure(note::init)
2021-05-02 12:32:03 +02:00
.configure(client::init)
.default_service(web::resource("").route(web::get().to(client::fallback_fn)))
2021-05-01 12:39:40 +02:00
})
2021-05-02 13:53:48 +02:00
.bind("0.0.0.0:5000")?
2021-05-01 12:39:40 +02:00
.run()
2021-12-20 17:42:16 +01:00
.await;
2021-05-01 12:39:40 +02:00
}