recipes/backend/src/services/fragments.rs

34 lines
799 B
Rust

use askama::Template;
use axum::{
debug_handler,
extract::{Extension, Query, State},
response::{Html, IntoResponse},
};
use common::web_api;
use crate::{
app::{Context, Result},
data::db,
html_templates::*,
};
#[debug_handler]
pub async fn recipes_list_fragments(
State(connection): State<db::Connection>,
params: Query<web_api::RecipesListFragmentsParams>,
Extension(context): Extension<Context>,
) -> Result<impl IntoResponse> {
Ok(Html(
RecipesListFragmentTemplate {
recipes: Recipes::new(
connection,
&context.user,
context.tr.current_lang_code(),
params.current_recipe_id,
)
.await?,
context,
}
.render()?,
))
}