2021-11-04 22:37:16 +00:00
|
|
|
#[macro_use]
|
|
|
|
extern crate diesel;
|
|
|
|
#[macro_use]
|
|
|
|
extern crate diesel_migrations;
|
|
|
|
extern crate dotenv;
|
|
|
|
|
2021-11-05 15:32:30 +00:00
|
|
|
use actix_web::{App, HttpServer, web};
|
|
|
|
|
|
|
|
mod db;
|
|
|
|
mod handlers;
|
|
|
|
mod types;
|
2021-11-04 22:37:16 +00:00
|
|
|
|
|
|
|
#[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),
|
|
|
|
)
|
2021-11-05 15:32:30 +00:00
|
|
|
.service(handlers::v1::schedules::show)
|
2021-11-04 22:37:16 +00:00
|
|
|
.route(
|
|
|
|
"/api/v1/schedules/{id}",
|
|
|
|
web::delete().to(handlers::v1::schedules::delete),
|
|
|
|
)
|
|
|
|
})
|
|
|
|
.bind("127.0.0.1:5000")?
|
|
|
|
.run()
|
|
|
|
.await
|
|
|
|
}
|