Add a RON API to search recipes by title + a bit of refactoring
This commit is contained in:
parent
a3f61e3711
commit
084f7ef445
26 changed files with 499 additions and 333 deletions
|
|
@ -6,7 +6,7 @@ use axum::{
|
|||
middleware::Next,
|
||||
response::{Html, IntoResponse, Response},
|
||||
};
|
||||
use serde::Deserialize;
|
||||
use serde::{self, Deserialize};
|
||||
|
||||
use crate::{
|
||||
app::{AppState, Context, Result},
|
||||
|
|
@ -109,7 +109,7 @@ pub async fn dev_panel(
|
|||
///// LOGS /////
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct LogFile {
|
||||
pub struct LogsParams {
|
||||
#[serde(default)]
|
||||
pub log_file: String,
|
||||
}
|
||||
|
|
@ -119,7 +119,7 @@ pub async fn logs(
|
|||
State(connection): State<db::Connection>,
|
||||
State(log): State<Log>,
|
||||
Extension(context): Extension<Context>,
|
||||
log_file: Query<LogFile>,
|
||||
Query(params): Query<LogsParams>,
|
||||
) -> Result<Response> {
|
||||
if context.user.is_some() && context.user.as_ref().unwrap().is_admin {
|
||||
Ok(Html(
|
||||
|
|
@ -133,11 +133,11 @@ pub async fn logs(
|
|||
.await?,
|
||||
context,
|
||||
current_log_file: match (
|
||||
log_file.log_file.is_empty(),
|
||||
params.log_file.is_empty(),
|
||||
log.file_names().unwrap_or_default(),
|
||||
) {
|
||||
(true, file_names) if !file_names.is_empty() => file_names[0].clone(),
|
||||
_ => log_file.log_file.clone(),
|
||||
_ => params.log_file.clone(),
|
||||
},
|
||||
log,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue