use actix_web::web::{get, post, resource};

pub fn add_routes(s: &mut actix_web::web::ServiceConfig) {
  let _ = s
    // Home
    .service(resource("/").name("home").route(get().to(crate::home::index)))
    .service(resource("/health").name("health").route(get().to(crate::home::health)))
    .service(resource("/profile").name("profile").route(get().to(crate::home::profile)).route(post().to(crate::home::profile_post)))
    .service(resource("/settings").name("settings").route(get().to(crate::home::settings)).route(post().to(crate::home::settings_post)))

    // WebSocket

    // Testbed
    .service(resource("/testbed/{key}").name("testbed.detail").route(get().to(crate::home::testbed_key)))

    //Project
    .service(resource("/project/new").name("project.new").route(get().to(crate::projects::new)).route(post().to(crate::projects::create)))
    .service(resource("/project/{key}").name("project.detail").route(get().to(crate::projects::detail)))
    .service(resource("/project/{key}/edit").name("project.edit").route(get().to(crate::projects::edit)).route(post().to(crate::projects::save)))

    .service(resource("/project/{key}/connect").name("connect").route(get().to(crate::websocket::connect)))

    // Static
    .service(resource("/favicon.ico").name("favicon").route(get().to(crate::static_file::favicon)))
    .service(resource("/static/{filename:.*}").name("static").route(get().to(crate::static_file::static_file)))

    // Catch-all
    .service(resource("/{path:.*}").name("missing").to(crate::not_found));
}
