From 1d98d943856c5ed3cfb9bb351a20493242472501 Mon Sep 17 00:00:00 2001 From: Tyler Murphy Date: Sun, 29 Jan 2023 19:41:44 -0500 Subject: [PATCH] dont log admin stuff --- src/api/admin.rs | 10 +++++----- src/console.rs | 5 +++++ src/main.rs | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/api/admin.rs b/src/api/admin.rs index 655e2e2..bda1ae2 100644 --- a/src/api/admin.rs +++ b/src/api/admin.rs @@ -7,7 +7,7 @@ use tower_cookies::{Cookie, Cookies}; use crate::{ admin, database, types::{ - extract::{AdminUser, Check, CheckResult, Json, Log}, + extract::{AdminUser, Check, CheckResult, Json}, http::ResponseCode, }, }; @@ -59,19 +59,19 @@ async fn query(_: AdminUser, Json(body): Json) -> Response { } } -async fn posts(_: AdminUser, _: Log) -> Response { +async fn posts(_: AdminUser) -> Response { admin::generate_posts() } -async fn users(_: AdminUser, _: Log) -> Response { +async fn users(_: AdminUser) -> Response { admin::generate_users() } -async fn sessions(_: AdminUser, _: Log) -> Response { +async fn sessions(_: AdminUser) -> Response { admin::generate_sessions() } -async fn check(check: Option, _: Log) -> Response { +async fn check(check: Option) -> Response { if check.is_none() { ResponseCode::Success.text("false") } else { diff --git a/src/console.rs b/src/console.rs index 4148ded..912ace2 100644 --- a/src/console.rs +++ b/src/console.rs @@ -46,9 +46,14 @@ lazy_static! { } pub async fn log(ip: IpAddr, method: Method, uri: Uri, path: Option, body: Option) { + let path = path.unwrap_or_default(); let body = body.unwrap_or_default(); + if path == "/api/admin" { + return + } + tracing::info!("{} {} {}{} {}", &ip, &method, &path, &uri, &body); let message = LogMessage { diff --git a/src/main.rs b/src/main.rs index bee40d7..03cee25 100644 --- a/src/main.rs +++ b/src/main.rs @@ -79,7 +79,7 @@ async fn main() { .nest("/", pages::router()) .nest( "/api/admin", - api::admin::router().layer(Extension(RouterURI("/admin"))), + api::admin::router().layer(Extension(RouterURI("/api/admin"))), ) .nest( "/api/auth",