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