diff --git a/public/views/admin-panel/index.html b/public/views/admin-panel/index.html index b9fc1fea3ed2f7165f1fc31c26001cda206df7fa..0baba8f8c22b79db750c0e91363d86e698c78987 100644 --- a/public/views/admin-panel/index.html +++ b/public/views/admin-panel/index.html @@ -15,7 +15,6 @@ FORM: update/delete article </main> </body> - <script src="/v/admin-panel/assets/script.js"></script> </html> \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 4b3b905d78a291a9c426ad782798a2c722aa3046..205600bcf25191f6faa0c856d749bedfed128a6a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -21,7 +21,7 @@ use app_state::AppState; use env::get_log_level; use env_logger::Env; use middleware::AuthenticatedAdminMiddleware; -use service::admin_auth::admin_auth; +use service::*; use standard_static_files::{favicon, robots, sitemap}; use std::env::var as env_var; use tls::get_tls_config; @@ -79,9 +79,15 @@ async fn main() -> std::io::Result<()> { }, ]))) .wrap(NormalizePath::new(TrailingSlash::Trim)) - .service(admin_auth) - // Allow json payload to have size until ~32MB - // .app_data(JsonConfig::default().limit(1 << 25u8)) + // .app_data(JsonConfig::default().limit(1 << 25u8)) // Allow json payload to have size until ~32MB + ///////////////////////////////////////////////////////////////////////////////////////////////////////////// + // REST API ///////////////////////////////////////////////////////////////////////////////////////////////// + .service(admin_authentication) + .service(post_article) + .service(update_article) + .service(delete_article) + .service(get_articles_by_category) + .service(get_article) ///////////////////////////////////////////////////////////////////////////////////////////////////////////// // STANDARD FILES /////////////////////////////////////////////////////////////////////////////////////////// .service(resource("/favicon.ico").route(get().to(favicon))) diff --git a/src/model.rs b/src/model.rs index b1c6c6fc9a9c137ad3577d3e30d87c7de36ca1be..6df3c2bbf1d8375ca1f8f94db9f87e36b472fbff 100644 --- a/src/model.rs +++ b/src/model.rs @@ -1,2 +1,4 @@ mod administrator; +mod article; pub use administrator::*; +pub use article::*; diff --git a/src/service.rs b/src/service.rs index ee031a2bfed8a87c699691c425cf5c996db73240..91376c0ac331b964e71130ef122c5047fb8a152c 100644 --- a/src/service.rs +++ b/src/service.rs @@ -1 +1,4 @@ -pub mod admin_auth; +mod admin_auth; +mod articles; +pub use admin_auth::*; +pub use articles::*; diff --git a/src/service/admin_auth.rs b/src/service/admin_auth.rs index 989c22fe9a2af59a6cddad38789e092b31ba8019..f3313cd16bb1876f688fff7a398fbef42ab4be4c 100644 --- a/src/service/admin_auth.rs +++ b/src/service/admin_auth.rs @@ -9,7 +9,7 @@ use actix_web::{ /// If the authentication succeed, a cookie with an auth token is returned /// If not, 401 is returned and if an auth cookie is found it is deleted. #[post("/admin-auth")] -pub async fn admin_auth<'a>( +pub async fn admin_authentication<'a>( app_state: Data<AppState>, auth_mw: Data<AuthenticatedAdminMiddleware<'a>>, req: HttpRequest, @@ -77,7 +77,7 @@ mod test_admin_auth { .app_data(Data::new(AuthenticatedAdminMiddleware::new( "kuadrado-admin-auth", ))) - .service(admin_auth), + .service(admin_authentication), ) .await; @@ -103,7 +103,7 @@ mod test_admin_auth { .app_data(Data::new(AuthenticatedAdminMiddleware::new( "kuadrado-admin-auth", ))) - .service(admin_auth), + .service(admin_authentication), ) .await;