dont log admin stuff

This commit is contained in:
Tyler Murphy 2023-01-29 19:41:44 -05:00
parent 8af75aef17
commit 1d98d94385
3 changed files with 11 additions and 6 deletions

View file

@ -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<QueryRequest>) -> 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<AdminUser>, _: Log) -> Response {
async fn check(check: Option<AdminUser>) -> Response {
if check.is_none() {
ResponseCode::Success.text("false")
} else {

View file

@ -46,9 +46,14 @@ lazy_static! {
}
pub async fn log(ip: IpAddr, method: Method, uri: Uri, path: Option<String>, body: Option<String>) {
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 {

View file

@ -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",