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