controller/src/main.rs

39 lines
902 B
Rust
Raw Normal View History

2021-11-04 22:37:16 +00:00
mod db;
mod handlers;
#[macro_use]
extern crate diesel;
#[macro_use]
extern crate diesel_migrations;
extern crate dotenv;
use actix_web::{web, App, HttpServer};
#[actix_web::main]
async fn main() -> std::io::Result<()> {
db::run_migrations();
HttpServer::new(|| {
App::new()
.route(
"/api/v1/schedules",
web::get().to(handlers::v1::schedules::index),
)
.route(
"/api/v1/schedules",
web::post().to(handlers::v1::schedules::add),
)
.route(
"/api/v1/schedules/{id}",
web::get().to(handlers::v1::schedules::get),
)
.route(
"/api/v1/schedules/{id}",
web::delete().to(handlers::v1::schedules::delete),
)
})
.bind("127.0.0.1:5000")?
.run()
.await
}