move axum_ructe to lib
This commit is contained in:
parent
bfb697e3b9
commit
c15046ae30
5 changed files with 14 additions and 13 deletions
|
@ -18,8 +18,8 @@ use futures_util::Stream;
|
|||
use serde::Deserialize;
|
||||
use tokio_stream::{wrappers::errors::BroadcastStreamRecvError, StreamExt as _};
|
||||
|
||||
use crate::axum_ructe::render;
|
||||
use crate::AppState;
|
||||
use cm_lib::render;
|
||||
|
||||
pub(crate) fn router() -> axum::Router<AppState> {
|
||||
axum::Router::new()
|
||||
|
|
|
@ -3,6 +3,7 @@ use axum::{
|
|||
response::{Html, IntoResponse},
|
||||
};
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! render {
|
||||
($template:path) => {{
|
||||
use $crate::axum_ructe::Render;
|
||||
|
@ -14,8 +15,6 @@ macro_rules! render {
|
|||
}}
|
||||
}
|
||||
|
||||
pub(crate) use render;
|
||||
|
||||
pub struct Render<T: FnOnce(&mut Vec<u8>) -> std::io::Result<()>>(pub T);
|
||||
|
||||
impl<T: FnOnce(&mut Vec<u8>) -> std::io::Result<()>> IntoResponse for Render<T> {
|
|
@ -1,4 +1,5 @@
|
|||
pub mod models;
|
||||
pub mod schema;
|
||||
pub mod report;
|
||||
pub mod axum_ructe;
|
||||
pub mod hx_request;
|
||||
pub mod models;
|
||||
pub mod report;
|
||||
pub mod schema;
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
mod api;
|
||||
mod axum_ructe;
|
||||
mod sse_handler;
|
||||
mod management;
|
||||
mod sse_handler;
|
||||
|
||||
use axum_ructe::render;
|
||||
use cm_lib::render;
|
||||
|
||||
use cm_lib::{
|
||||
hx_request::HxRequest,
|
||||
models::{Drink, Shift},
|
||||
report::GenerateDrinkReport,
|
||||
schema::shifts, hx_request::HxRequest,
|
||||
schema::shifts,
|
||||
};
|
||||
|
||||
use axum::{
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
use axum::{routing::get, response::IntoResponse};
|
||||
use axum::{response::IntoResponse, routing::get};
|
||||
|
||||
use crate::{AppState, axum_ructe::render};
|
||||
use crate::AppState;
|
||||
|
||||
use cm_lib::render;
|
||||
|
||||
pub(crate) fn router() -> axum::Router<AppState> {
|
||||
axum::Router::new()
|
||||
|
@ -12,7 +14,6 @@ async fn home() -> impl IntoResponse {
|
|||
render!(crate::templates::management_html)
|
||||
}
|
||||
|
||||
|
||||
async fn dancers() -> impl IntoResponse {
|
||||
render!(crate::templates::dancers_html)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue