feat: Add tracing and md5 dependency
Adds the `tracing` and `md5` crates to the project, enabling enhanced logging and cryptographic hashing capabilities. Includes `TraceLayer` for HTTP request tracing and configures `tracing-subscriber` with `EnvFilter`.
This commit is contained in:
@@ -1,17 +1,51 @@
|
||||
use crate::state::AppState;
|
||||
use crate::schema::users;
|
||||
use crate::types::types::OpenSubSonicResponses;
|
||||
use crate::{state::AppState, types::types::OpenSubsonicAuth};
|
||||
use axum::extract::State;
|
||||
use axum::{Json, Router, http::StatusCode, routing::get};
|
||||
use diesel::{ExpressionMethods, QueryDsl, RunQueryDsl};
|
||||
|
||||
pub fn system_routers() -> Router<AppState> {
|
||||
Router::new().route(
|
||||
"/getOpenSubsonicExtensions",
|
||||
get(get_opensubsonic_extentions).post(get_opensubsonic_extentions),
|
||||
Router::new()
|
||||
.route(
|
||||
"/getOpenSubsonicExtensions.view",
|
||||
get(get_opensubsonic_extensions).post(get_opensubsonic_extensions),
|
||||
)
|
||||
.route("/ping.view", get(ping).post(ping))
|
||||
.route("/license.view", get(license).post(license))
|
||||
}
|
||||
|
||||
async fn license(
|
||||
State(db_con): State<AppState>,
|
||||
user: OpenSubsonicAuth,
|
||||
) -> (StatusCode, Json<OpenSubSonicResponses>) {
|
||||
let conn = &mut db_con.pool.get().unwrap();
|
||||
let result = users::table
|
||||
.select(users::email)
|
||||
.filter(users::username.eq(user.username))
|
||||
.first::<String>(conn);
|
||||
match result {
|
||||
Ok(e) => (
|
||||
StatusCode::OK,
|
||||
Json(OpenSubSonicResponses::license_response(Some(e))),
|
||||
),
|
||||
Err(_) => (
|
||||
StatusCode::OK,
|
||||
Json(OpenSubSonicResponses::license_response(None)),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
async fn ping(_user: OpenSubsonicAuth) -> (StatusCode, Json<OpenSubSonicResponses>) {
|
||||
(
|
||||
StatusCode::OK,
|
||||
Json(OpenSubSonicResponses::open_subsonic_response()),
|
||||
)
|
||||
}
|
||||
|
||||
async fn get_opensubsonic_extentions() -> (StatusCode, Json<OpenSubSonicResponses>) {
|
||||
async fn get_opensubsonic_extensions() -> (StatusCode, Json<OpenSubSonicResponses>) {
|
||||
(
|
||||
StatusCode::OK,
|
||||
Json(OpenSubSonicResponses::open_subsonic_extentions()),
|
||||
Json(OpenSubSonicResponses::open_subsonic_extensions()),
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user