Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects
Commit f9a90661 authored by Pierre Jarriges's avatar Pierre Jarriges
Browse files

crud articles

parent 5eba8a48
No related branches found
No related tags found
No related merge requests found
......@@ -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
......@@ -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)))
......
mod administrator;
mod article;
pub use administrator::*;
pub use article::*;
pub mod admin_auth;
mod admin_auth;
mod articles;
pub use admin_auth::*;
pub use articles::*;
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment