use poem::{delete, post, put, EndpointExt}; use poem::{get, listener::TcpListener, Route, Server}; use critch::config::Config; use critch::routes; use critch::Critch; #[tokio::main] async fn main() -> Result<(), std::io::Error> { let config = Config::from_file("./critch.toml").unwrap(); let state = Critch::new(config).await; let app = Route::new() .at( "/admin", post(routes::admin::login).get(routes::admin::get_login_form), ) .at("/", get(routes::artworks::get)) .at( "/artworks", get(routes::artworks::get).post(routes::artworks::post), ) .at( "/artworks/:artwork", get(routes::artworks::get) .put(routes::artworks::put) .delete(routes::artworks::delete), ) .at( "/artists", get(routes::artists::get).post(routes::artists::post), ) .at( "/artists/:artist", get(routes::artists::get) .put(routes::artists::put) .delete(routes::artists::delete), ) .at( "/artworks/:artwork/comments", post(routes::artworks::comments::post).delete(routes::artworks::comments::delete), ) .data(state); Server::new(TcpListener::bind("0.0.0.0:3000")) .run(app) .await?; Ok(()) }