1pub mod app;
24pub mod conf;
25pub mod defaults;
26pub mod matcher;
27pub mod packaging;
28pub mod render;
29pub mod types;
30
31pub use render::*;
32pub use types::*;
33
34#[macro_export]
35macro_rules! rumtk_web_get_text_item {
36 ( $store:expr, $item:expr, $default:expr) => {{
37 match $store.get($item) {
38 Some(x) => x,
39 None => $default,
40 }
41 }};
42}
43
44#[macro_export]
45macro_rules! rumtk_web_get_param_eq {
46 ( $params:expr, $indx:expr, $comparison:expr, $default:expr ) => {{
47 match $params.get($indx) {
48 Some(x) => *x == $comparison,
49 None => $default,
50 }
51 }};
52}
53
54#[macro_export]
55macro_rules! rumtk_web_get_param {
56 ( $params:expr, $indx:expr, $default:expr ) => {{
57 match $params.get($indx) {
58 Some(x) => x.parse().unwrap_or($default),
59 None => $default,
60 }
61 }};
62}
63
64#[macro_export]
65macro_rules! rumtk_web_params_map {
66 ( $params:expr ) => {{
67 use std::collections::HashMap;
68 let mut params = HashMap::<RUMString, RUMString>::with_capacity($params.len());
69
70 for (k, v) in $params.iter() {
71 params.insert(
72 RUMString::from(k.to_string()),
73 RUMString::from(v.to_string()),
74 );
75 }
76 params
77 }};
78}
79
80#[macro_export]
81macro_rules! rumtk_web_fetch {
82 ( $matcher:expr ) => {{
83 use axum::extract::{Path, Query, State};
84 use axum::response::Html;
85 use $crate::utils::types::{RouterAppConf, RouterComponents, RouterParams};
86
87 async |Path(path_params): RouterComponents,
88 Query(params): RouterParams,
89 State(state): RouterAppConf|
90 -> Html<String> {
91 match $matcher(path_params, params, state).await {
92 Ok(res) => res,
93 Err(e) => {
94 error!("{}", e);
95 return Html(String::default());
96 }
97 }
98 }
99 }};
100}