#![allow(non_snake_case)]
#[cfg(feature = "thread_shared_struct")]
#[macro_export]
macro_rules! InitControllersRoot {
{
name: $name:ident ,
holder_type:$holder:ty,
shared_type:$shared:ty,
} => {
InitControllersRoot! {
name:$name,
holder_type:$holder,
shared_type:$shared,
headers_length:16,
queries_length:16
}
};
{
name: $name:ident ,
holder_type:$holder:ty,
shared_type:$shared:ty,
headers_length:$hl:literal,
queries_length:$ql:literal
} => {
use water_http::server::matcher::*;
pub static mut $name:Option<water_http::server::CapsuleWaterController<$holder,$shared,$hl,$ql>> = None;
pub static mut STATIC_PATHS: Option<std::collections::HashMap<String, PathHolder<$holder,$shared,$hl,$ql>>> = None;
pub static mut DYNAMIC_PATHS: Option<std::collections::HashMap<usize, DynamicPathVec<$holder,$shared,$hl,$ql>>> = None;
};
{
$name:ident ,
$holder:ty,
$shared:ty,
} => {
InitControllersRoot! {
name:$name,
holder_type:$holder,
shared_type:$shared,
headers_length:16,
queries_length:16
}
};
{
$name:ident ,
$holder:ty,
$shared:ty,
$hl:literal
} => {
InitControllersRoot! {
name:$name,
holder_type:$holder,
shared_type:$shared,
headers_length:$hl,
queries_length:16
}
};
{
$name:ident ,
$holder:ty,
$shared:ty,
$hl:literal,
$hq:literal
} => {
InitControllersRoot! {
name:$name,
holder_type:$holder,
shared_type:$shared,
headers_length:$hl,
queries_length:$hq
}
};
}
#[cfg(not(feature = "thread_shared_struct"))]
#[macro_export]
macro_rules! InitControllersRoot {
{
name: $name:ident ,
holder_type:$holder:ty,
} => {
InitControllersRoot! {
name:$name,
holder_type:$holder,
headers_length:16,
queries_length:16
}
};
{
name: $name:ident ,
holder_type:$holder:ty,
headers_length:$hl:literal,
queries_length:$ql:literal
} => {
use water_http::server::matcher::*;
pub static mut $name:Option<water_http::server::CapsuleWaterController<$holder,$hl,$ql>> = None;
pub static mut STATIC_PATHS: Option<std::collections::HashMap<String, PathHolder<$holder,$hl,$ql>>> = None;
pub static mut DYNAMIC_PATHS: Option<std::collections::HashMap<usize, DynamicPathVec<$holder,$hl,$ql>>> = None;
};
{
$name:ident ,
$holder:ty
} => {
InitControllersRoot! {
name:$name,
holder_type:$holder,
headers_length:16,
queries_length:16
}
};
{
$name:ident ,
$holder:ty,
$hl:literal
} => {
InitControllersRoot! {
name:$name,
holder_type:$holder,
headers_length:$hl,
queries_length:16
}
};
{
$name:ident ,
$holder:ty,
$hl:literal,
$hq:literal
} => {
InitControllersRoot! {
name:$name,
holder_type:$holder,
headers_length:$hl,
queries_length:$hq
}
};
}
#[macro_export]
macro_rules! route {
($key:expr) => {
{
water_http::server::___get_from_all_routes($key,None)
}
};
($key:expr,[$($k:expr => $value:expr),*]) => {
{
let mut map:std::collections::HashMap<&str,&str> = std::collections::HashMap::new();
$(map.insert($k,$value);)*
water_http::server::___get_from_all_routes($key,Some(map))
}
};
}
#[cfg(feature = "thread_shared_struct")]
#[macro_export]
macro_rules! RunServer {
(
$config:expr,
$controller:expr,
$entry:ident,
$shared_factory:expr
) => {
#[allow(static_mut_refs)]
unsafe {
let co = $entry::build();
$controller = Some(co);
water_http::server::run_server(
$config,
$controller.as_mut().unwrap(),
$shared_factory,
&mut STATIC_PATHS,
&mut DYNAMIC_PATHS
);
};
};
}
#[cfg(not(feature = "thread_shared_struct"))]
#[macro_export]
macro_rules! RunServer {
(
$config:expr,
$controller:expr,
$entry:ident
) => {
#[allow(static_mut_refs)]
unsafe {
let co = $entry::build();
$controller = Some(co);
water_http::server::run_server(
$config,
$controller.as_mut().unwrap(),
&mut STATIC_PATHS,
&mut DYNAMIC_PATHS
);
};
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! FunctionsMacroBuilderTow {
(
@entry
functions -> { $($items:tt)* }
) => {
water_http::FunctionsMacroBuilderTow! (
@parse [],
$($items)*
);
};
(
@parse [ $($acc:tt)* ],
$method:ident => $($path:tt)/+ => $fn_name:ident ( $context:ident ) $async:tt { $($body:tt)* } $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow! (
@parse [
$($acc)*
$method => $($path)/+ => $fn_name($context) $async { $($body)* },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$method:ident -> $($path:tt)/+ -> $fn_name:ident ( $context:ident ) $async:tt { $($body:tt)* } $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow! (
@parse [
$($acc)*
$method => $($path)/+ => $fn_name($context) $async { $($body)* },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$method:ident => $($path:tt)/+ => $fn_name:ident ( $context:ident ) $async:tt [$fn_path:path] $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow! (
@parse [
$($acc)*
$method => $($path)/+ => $fn_name($context) $async {
$fn_path($context).await;
},
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$method:ident -> $($path:tt)/+ -> $fn_name:ident ( $context:ident ) $async:tt [$fn_path:path] $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow! (
@parse [
$($acc)*
$method => $($path)/+ => $fn_name($context) $async {
$fn_path($context).await;
},
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$method:ident => $($path:tt)/+ => $fn_name:ident ( $context:ident ) [$fn_path:path] $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow! (
@parse [
$($acc)*
$method => $($path)/+ => $fn_name($context) async {
$fn_path($context).await;
},
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$method:ident -> $($path:tt)/+ -> $fn_name:ident ( $context:ident ) [$fn_path:path] $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow! (
@parse [
$($acc)*
$method => $($path)/+ => $fn_name($context) async {
$fn_path($context).await;
},
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$method:ident => $($path:tt)/+ => $fn_name:ident ( $context:ident ) { $($body:tt)* } $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
$method => $($path)/+ => $fn_name($context) async { $($body)* },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$method:ident -> $($path:tt)/+ -> $fn_name:ident ( $context:ident ) { $($body:tt)* } $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
$method => $($path)/+ => $fn_name($context) async { $($body)* },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$method:ident => $fn_name:ident ( $context:ident ) { $($body:tt)* } $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
$method => $fn_name => $fn_name($context) async { $($body)* },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$method:ident -> $fn_name:ident ( $context:ident ) { $($body:tt)* } $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
$method => $fn_name => $fn_name($context) async { $($body)* },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$method:ident => $fn_name:ident ( $context:ident ) [$fn_path:path] $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
$method => $fn_name => $fn_name($context) async { $fn_path($context).await },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$method:ident -> $fn_name:ident ( $context:ident ) [$fn_path:path] $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
$method => $fn_name => $fn_name($context) async { $fn_path($context).await },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$method:ident => $fn_name:ident ( $context:ident ) $async:tt [$fn_path:path] $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
$method => $fn_name => $fn_name($context) $async { $fn_path($context).await },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$method:ident -> $fn_name:ident ( $context:ident ) $async:tt [$fn_path:path] $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
$method => $fn_name => $fn_name($context) $async { $fn_path($context).await },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$method:ident => $fn_name:ident ( $context:ident ) $async:tt { $($body:tt)* } $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
$method => $fn_name => $fn_name($context) $async { $($body)* },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$method:ident -> $fn_name:ident ( $context:ident ) $async:tt { $($body:tt)* } $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
$method => $fn_name => $fn_name($context) $async { $($body)* },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$($path:tt)/+ => $fn_name:ident ( $context:ident ) { $($body:tt)* } $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
GET => $($path)/+ => $fn_name($context) async { $($body)* },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$($path:tt)/+ -> $fn_name:ident ( $context:ident ) { $($body:tt)* } $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
GET => $($path)/+ => $fn_name($context) async { $($body)* },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$($path:tt)/+ => $fn_name:ident ( $context:ident ) [$fn_path:path] $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
GET => $($path)/+ => $fn_name($context) async {
$fn_path($context).await;
},
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$($path:tt)/+ -> $fn_name:ident ( $context:ident ) [$fn_path:path] $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
GET => $($path)/+ => $fn_name($context) async {
$fn_path($context).await;
},
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$($path:tt)/+ => $fn_name:ident ( $context:ident ) $async:tt { $($body:tt)* } $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
GET => $($path)/+ => $fn_name($context) $async { $($body)* },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$($path:tt)/+ -> $fn_name:ident ( $context:ident ) $async:tt { $($body:tt)* } $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
GET => $($path)/+ => $fn_name($context) $async { $($body)* },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$($path:tt)/+ => $fn_name:ident ( $context:ident ) $async:tt [$fn_path:path] $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
GET => $($path)/+ => $fn_name($context) $async { $fn_path($context).await; },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$($path:tt)/+ -> $fn_name:ident ( $context:ident ) $async:tt [$fn_path:path] $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
GET => $($path)/+ => $fn_name($context) $async { $fn_path($context).await; },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$fn_name:ident ( $context:ident ){ $($body:tt)* } $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
GET => $fn_name => $fn_name($context) async { $($body)* },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$fn_name:ident ( $context:ident )[$fn_path:path] $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
GET => $fn_name => $fn_name($context) async {
$fn_path($context).await;
},
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$fn_name:ident ( $context:ident ) $async:tt { $($body:tt)* } $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
GET => $fn_name => $fn_name($context) $async { $($body)* },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$fn_name:ident ( $context:ident ) $async:tt [$fn_path:path] $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
GET => $fn_name => $fn_name($context) $async { $fn_path($context).await; },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$method:ident $fn_name:ident ( $context:ident ) $async:tt { $($body:tt)* } $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
$method => / => $fn_name($context) $async { $($body)* },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$method:ident $fn_name:ident ( $context:ident ) $async:tt [$fn_path:path] $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
$method => / => $fn_name($context) $async { $fn_path($context).await; },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$method:ident $fn_name:ident ( $context:ident ) { $($body:tt)* } $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
$method => / => $fn_name($context) async { $($body)* },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$method:ident $fn_name:ident ( $context:ident ) [$fn_path:path] $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
$method => / => $fn_name($context) async { $fn_path($context).await },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$($path:tt)/+ $fn_name:ident ( $context:ident ) { $($body:tt)* } $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
GET => $($path)/+ => $fn_name($context) async { $($body)* },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$($path:tt)/+ $fn_name:ident ( $context:ident ) [$fn_path:path] $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
GET => $($path)/+ => $fn_name($context) async { $fn_path($context).await },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$($path:tt)/+ $fn_name:ident ( $context:ident ) $async:tt { $($body:tt)* } $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
GET => $($path)/+ => $fn_name($context) $async { $($body)* },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$($path:tt)/+ $fn_name:ident ( $context:ident ) $async:tt [$fn_path:path] $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
GET => $($path)/+ => $fn_name($context) $async { $fn_path($context).await },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$path:literal $fn_name:ident ( $context:ident ) { $($body:tt)* } $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
GET => $path => $fn_name($context) async { $($body)* },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$path:literal $fn_name:ident ( $context:ident ) [$fn_path:path] $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
GET => $path => $fn_name($context) async { $fn_path($context).await },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$path:literal $fn_name:ident ( $context:ident ) $async:tt { $($body:tt)* } $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
GET => $path => $fn_name($context) $async { $($body)* },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$path:literal $fn_name:ident ( $context:ident ) $async:tt [$fn_path:path] $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
GET => $path => $fn_name($context) $async { $fn_path($context).await },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$method:ident $($path:tt)/+ $fn_name:ident ( $context:ident ) $async:tt { $($body:tt)* } $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
$method => $($path)/+ => $fn_name($context) $async { $($body)* },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$method:ident $($path:tt)/+ $fn_name:ident ( $context:ident ) $async:tt [$fn_path:path] $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
$method => $($path)/+ => $fn_name($context) $async { $fn_path($context).await },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$method:ident $($path:tt)/+ $fn_name:ident ( $context:ident ) { $($body:tt)* } $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
$method => $($path)/+ => $fn_name($context) async { $($body)* },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$method:ident $($path:tt)/+ $fn_name:ident ( $context:ident ) [$fn_path:path] $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
$method => $($path)/+ => $fn_name($context) async { $fn_path($context).await },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$method:ident $path:tt $fn_name:ident ( $context:ident ) $async:tt { $($body:tt)* } $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
$method => $path => $fn_name($context) $async { $($body)* },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$method:ident $path:tt $fn_name:ident ( $context:ident ) $async:tt [$fn_path:path] $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
$method => $path => $fn_name($context) $async { $fn_path($context).await },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$method:ident $path:tt $fn_name:ident ( $context:ident ) { $($body:tt)* } $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
$method => $path => $fn_name($context) async { $($body)* },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
$method:ident $path:tt $fn_name:ident ( $context:ident ) [$fn_path:path] $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
$method => $path => $fn_name($context) async { $fn_path($context).await },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
#[$method:ident,$($path:tt)/+]
$async:tt $fn_name:ident($context:ident) { $($body:tt)* } $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
$method => $($path)/+ => $fn_name($context) $async { $($body)* },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
#[$method:ident,$($path:tt)/+]
$fn_name:ident($context:ident) $async:tt { $($body:tt)* } $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
$method => $($path)/+ => $fn_name($context) $async { $($body)* },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
#[$method:ident,$($path:tt)/+]
$async:tt $fn_name:ident($context:ident) [$fn_path:path] $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
$method => $($path)/+ => $fn_name($context) $async {
$fn_path($context).await
},
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
#[$method:ident,$($path:tt)/+]
$fn_name:ident($context:ident)$async:tt [$fn_path:path] $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
$method => $($path)/+ => $fn_name($context) $async {
$fn_path($context).await
},
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
#[$method:ident,$($path:tt)/+]
$fn_name:ident($context:ident) { $($body:tt)* } $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
$method => $($path)/+ => $fn_name($context) async { $($body)* },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
#[$method:ident,$($path:tt)/+]
$fn_name:ident($context:ident) [$fn_path:path] $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
$method => $($path)/+ => $fn_name($context) async {
$fn_path($context).await
},
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
#[$method:ident,$($path:tt)/+]
$async:tt fn $fn_name:ident($context:ident) { $($body:tt)* } $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
$method => $($path)/+ => $fn_name($context) $async { $($body)* },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
#[$method:ident,$($path:tt)/+]
$async:tt fn $fn_name:ident($context:ident) [$fn_path:path] $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
$method => $($path)/+ => $fn_name($context) $async {
$fn_path($context).await
},
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
#[$method:ident,$($path:tt)/+]
fn $fn_name:ident($context:ident) { $($body:tt)* } $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
$method => $($path)/+ => $fn_name($context) async { $($body)* },
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
#[$method:ident,$($path:tt)/+]
fn $fn_name:ident($context:ident) [$fn_path:path] $($rest:tt)*
) => {
water_http::FunctionsMacroBuilderTow!( @parse [
$($acc)*
$method => $($path)/+ => $fn_name($context) async {
$fn_path($context).await
},
],
$($rest)*
);
};
(
@parse [ $($acc:tt)* ],
) => {
FunctionsMacroBuilder!(
functions->{
$($acc)*
}
);
};
}
#[cfg(feature = "thread_shared_struct")]
#[doc(hidden)]
#[macro_export]
macro_rules! FunctionsMacroBuilder {
(
functions -> {
$(
#[route($method:ident,$($path:tt)/+)]
fn $fn_name:ident($context:ident) {
$($function_body_tokens:tt)*
}
),*
}
) =>{
water_http::FunctionsMacroBuilder!(
functions -> {
$(
$method => $($path)/+ => $fn_name($context) $async {
$($function_body_tokens)*
}
),*
}
);
};
(
functions -> {
$(
#[route($method:ident,$($path:tt)/+)]
pub async $fn_name:ident($context:ident) {
$($function_body_tokens:tt)*
}
),*
}
) =>{
water_http::FunctionsMacroBuilder!(
functions -> {
$(
$method => $($path)/+ => $fn_name($context) $async {
$($function_body_tokens)*
}
),*
}
);
};
(
functions -> {
$(
#[route($method:ident,$($path:tt)/+)]
pub async fn $fn_name:ident($context:ident) {
$($function_body_tokens:tt)*
}
),*
}
) =>{
water_http::FunctionsMacroBuilder!(
functions -> {
$(
$method => $($path)/+ => $fn_name($context) $async {
$($function_body_tokens)*
}
),*
}
);
};
(
functions -> {
$(
#[route($method:ident,$($path:tt)/+)]
$async:tt $fn_name:ident($context:ident) {
$($function_body_tokens:tt)*
}
),*
}
) => {
water_http::FunctionsMacroBuilder!(
functions -> {
$(
$method => $($path)/+ => $fn_name($context) $async {
$($function_body_tokens)*
}
),*
}
);
};
(
functions -> {
$(
#[route($method:ident,$($path:tt)/+)]
$fn_name:ident($context:ident) {
$($function_body_tokens:tt)*
}
),*
}
) => {
water_http::FunctionsMacroBuilder!(
functions -> {
$(
$method => $($path)/+ => $fn_name($context) async {
$($function_body_tokens)*
}
),*
}
);
};
(
functions -> {
$(
$($path:tt)/+ => $fn_name:ident($context:ident) {
$($function_body_tokens:tt)*
}
),*
}
) => {
water_http::FunctionsMacroBuilder!(
functions -> {
$(
GET => $($path)/+ => $fn_name($context) async {
$($function_body_tokens)*
}
),*
}
);
};
(
functions -> {
$(
$($path:tt)/+ => $fn_name:ident($context:ident) $async:tt {
$($function_body_tokens:tt)*
}
),*
}
) => {
water_http::FunctionsMacroBuilder!(
functions -> {
$(
GET => $($path)/+ => $fn_name($context) $async {
$($function_body_tokens)*
}
),*
}
);
};
(
functions -> {
$(
$method:ident => $($path:tt)/+ => $fn_name:ident($context:ident) {
$($function_body_tokens:tt)*
}
),*
}
) => {
water_http::FunctionsMacroBuilder!(
functions -> {
$(
$method => $($path)/+ => $fn_name($context) async {
$($function_body_tokens)*
}
),*
}
);
};
(
functions -> {
$(
$method:ident => $($path:tt)/+ => $fn_name:ident($context:ident) $async:tt {
$($function_body_tokens:tt)*
},
)*
}
) => {
$(pub $async fn $fn_name<'context,
const header_length:usize,const query_length:usize>
($context:&mut water_http::server::HttpContext<'context,Holder,Shared,header_length,query_length>) {
water_http::path_setter!($context->$($path)/+);
$($function_body_tokens)*
}
)*
pub fn build<const header_length:usize,const query_length:usize>()->
water_http::server::CapsuleWaterController<Holder,Shared,header_length,query_length>{
let mut controller = water_http::server::CapsuleWaterController::new();
$(
controller.push_handler(
(
stringify!($method).replace('"',"").replace(" ",""),
stringify!($($path)/+).replace('"',"").replace(" ","").replace("//","/"),
| context | unsafe{std::pin::Pin::new_unchecked(
smallbox::smallbox!( async move {
$fn_name(context).await;
}))}
)
);
)*
check_up_controller(&mut controller);
controller
}
};
}
#[cfg(not(feature = "thread_shared_struct"))]
#[doc(hidden)]
#[macro_export]
macro_rules! FunctionsMacroBuilder {
(
functions -> {
$(
#[route($method:ident,$($path:tt)/+)]
fn $fn_name:ident($context:ident) {
$($function_body_tokens:tt)*
}
),*
}
) =>{
water_http::FunctionsMacroBuilder!(
functions -> {
$(
$method => $($path)/+ => $fn_name($context) $async {
$($function_body_tokens)*
}
),*
}
);
};
(
functions -> {
$(
#[route($method:ident,$($path:tt)/+)]
pub async $fn_name:ident($context:ident) {
$($function_body_tokens:tt)*
}
),*
}
) =>{
water_http::FunctionsMacroBuilder!(
functions -> {
$(
$method => $($path)/+ => $fn_name($context) $async {
$($function_body_tokens)*
}
),*
}
);
};
(
functions -> {
$(
#[route($method:ident,$($path:tt)/+)]
pub async fn $fn_name:ident($context:ident) {
$($function_body_tokens:tt)*
}
),*
}
) =>{
water_http::FunctionsMacroBuilder!(
functions -> {
$(
$method => $($path)/+ => $fn_name($context) $async {
$($function_body_tokens)*
}
),*
}
);
};
(
functions -> {
$(
#[route($method:ident,$($path:tt)/+)]
$async:tt $fn_name:ident($context:ident) {
$($function_body_tokens:tt)*
}
),*
}
) => {
water_http::FunctionsMacroBuilder!(
functions -> {
$(
$method => $($path)/+ => $fn_name($context) $async {
$($function_body_tokens)*
}
),*
}
);
};
(
functions -> {
$(
#[route($method:ident,$($path:tt)/+)]
$fn_name:ident($context:ident) {
$($function_body_tokens:tt)*
}
),*
}
) => {
water_http::FunctionsMacroBuilder!(
functions -> {
$(
$method => $($path)/+ => $fn_name($context) async {
$($function_body_tokens)*
}
),*
}
);
};
(
functions -> {
$(
$($path:tt)/+ => $fn_name:ident($context:ident) {
$($function_body_tokens:tt)*
}
),*
}
) => {
water_http::FunctionsMacroBuilder!(
functions -> {
$(
GET => $($path)/+ => $fn_name($context) async {
$($function_body_tokens)*
}
),*
}
);
};
(
functions -> {
$(
$($path:tt)/+ => $fn_name:ident($context:ident) $async:tt {
$($function_body_tokens:tt)*
}
),*
}
) => {
water_http::FunctionsMacroBuilder!(
functions -> {
$(
GET => $($path)/+ => $fn_name($context) $async {
$($function_body_tokens)*
}
),*
}
);
};
(
functions -> {
$(
$method:ident => $($path:tt)/+ => $fn_name:ident($context:ident) {
$($function_body_tokens:tt)*
}
),*
}
) => {
water_http::FunctionsMacroBuilder!(
functions -> {
$(
$method => $($path)/+ => $fn_name($context) async {
$($function_body_tokens)*
}
),*
}
);
};
(
functions -> {
$(
$method:ident => $($path:tt)/+ => $fn_name:ident($context:ident) $async:tt {
$($function_body_tokens:tt)*
},
)*
}
) => {
$(pub $async fn $fn_name<'context,CONTEXT_HOLDER:Send + 'static,const header_length:usize,const query_length:usize>
($context:&mut water_http::server::HttpContext<'context,CONTEXT_HOLDER,header_length,query_length>) {
water_http::path_setter!($context->$($path)/+);
$($function_body_tokens)*
}
)*
pub fn build<const header_length:usize,const query_length:usize>()->
water_http::server::CapsuleWaterController<Holder,header_length,query_length>{
let mut controller = water_http::server::CapsuleWaterController::new();
$(
controller.push_handler(
(
stringify!($method).replace('"',"").replace(" ",""),
stringify!($($path)/+).replace('"',"").replace(" ","").replace("//","/"),
| context | unsafe{std::pin::Pin::new_unchecked(
smallbox::smallbox!( async move {
$fn_name(context).await;
}))}
)
);
)*
check_up_controller(&mut controller);
controller
}
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! CheckupAutoGenerator {
( $controller:path >> prefix->$value:expr) => {
$controller.prefix = Some($value);
};
( $controller:path >> apply_parents_middlewares->$value:expr) => {
$controller.apply_parents_middlewares = $value;
};
( $controller:path >> apply_parents_interceptors->$value:expr) => {
$controller.apply_parents_interceptors = $value;
};
( $controller:path >> middleware-> $context:ident $block:block) => {
#[cfg(not(feature = "thread_shared_struct"))]
{
$controller.middleware = Some(
|$context :&mut HttpContext<Holder,header_length,query_length>| unsafe{std::pin::Pin::new_unchecked(smallbox::smallbox!( async move $block))});
}
#[cfg(feature = "thread_shared_struct")]
{
$controller.middleware = Some(
|$context :&mut HttpContext<Holder,Shared,header_length,query_length>| unsafe {std::pin::Pin::new_unchecked(smallbox::smallbox!( async move $block))});
}
};
( $controller:path >> interceptor-> $context:ident $block:block) => {
#[cfg(not(feature = "thread_shared_struct"))]
{
$controller.interceptor = Some(
|$context :&mut HttpContext<Holder,header_length,query_length>| unsafe{std::pin::Pin::new_unchecked(smallbox::smallbox!( async move $block))});
}
#[cfg(feature = "thread_shared_struct")]
{
$controller.interceptor = Some(
|$context :&mut HttpContext<Holder,Shared,header_length,query_length>| unsafe {std::pin::Pin::new_unchecked(smallbox::smallbox!( async move $block))});
}
};
($controller:path >> children-> [$($child:ident),*] )=>{
$(
$controller.push_controller(super::$child::build());
)*
};
($controller:path >> extra_code-> .. {$($tokens:tt)* }) => {}
}
#[doc(hidden)]
#[macro_export]
macro_rules! CheckExtraCode {
(extra_code -> .. {$($b:tt)*} ) => {
$($b)*
};
($key:tt -> $($tokens:tt)* ) => {
};
}
#[cfg(feature = "thread_shared_struct")]
#[macro_export]
macro_rules! WaterController {
{
holder -> $holder:path,
shared -> $shared:ty,
name -> $name:ident,
functions -> {$($function_tokens:tt)*}
$($key:tt -> ($($value:tt)*)),*
} => {
#[allow(non_snake_case)]
pub mod $name {
use water_http::http::{HttpSenderTrait,request::{HttpGetterTrait,IBodyChunks,IBody,ParsingBodyResults,ParsingBodyMechanism}};
use water_http::server::HttpContext;
use water_http::*;
pub type Holder = $holder;
pub type Shared = $shared;
water_http::FunctionsMacroBuilderTow!(
@entry
functions -> {$($function_tokens)*}
);
$(
water_http::CheckExtraCode!(
$key -> $($value)*
);
)*
fn check_up_controller
<const header_length:usize,const query_length:usize>(controller:&mut water_http::server::CapsuleWaterController<Holder,Shared,header_length,query_length>){
$(
water_http::CheckupAutoGenerator!(
controller >> $key -> $($value)*
);
)*
}
}
};
{
holder -> $holder:path,
name -> $name:ident,
functions -> {$($function_tokens:tt)*} $separator:tt
$($key:tt -> ($($value:tt)*)),*
} => {
water_http::WaterController!(
holder -> $holder,
name -> $name,
functions -> { $($function_tokens)* }
$($key -> ($($value)*)),*
);
};
}
#[cfg(not(feature = "thread_shared_struct"))]
#[macro_export]
macro_rules! WaterController {
{
holder -> $holder:path,
name -> $name:ident,
functions -> {$($function_tokens:tt)*}
$($key:tt -> ($($value:tt)*)),*
} => {
#[allow(non_snake_case)]
pub mod $name {
use water_http::http::{HttpSenderTrait,request::{HttpGetterTrait,IBodyChunks,IBody,ParsingBodyResults,ParsingBodyMechanism}};
use water_http::server::HttpContext;
use water_http::*;
pub type Holder = $holder;
water_http::FunctionsMacroBuilderTow!(
@entry
functions -> {$($function_tokens)*}
);
$(
water_http::CheckExtraCode!(
$key -> $($value)*
);
)*
fn check_up_controller
<const header_length:usize,const query_length:usize>(controller:&mut water_http::server::CapsuleWaterController<Holder,header_length,query_length>){
$(
water_http::CheckupAutoGenerator!(
controller >> $key -> $($value)*
);
)*
}
}
};
{
holder -> $holder:path,
name -> $name:ident,
functions -> {$($function_tokens:tt)*} $separator:tt
$($key:tt -> ($($value:tt)*)),*
} => {
water_http::WaterController!(
holder -> $holder,
name -> $name,
functions -> { $($function_tokens)* }
$($key -> ($($value)*)),*
);
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! path_setter {
[$context_name:ident () {$path_item:tt} ]=>{
let $path_item = $context_name.get_from_path_params(stringify!($path_item)).unwrap();
};
[$context_name:ident () $path_item:tt]=>{
};
( $context_name:ident -> $($p_item:tt)/+) => {
$(
water_http::path_setter![$context_name () $p_item ];
)+
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! response {
($context:ident -> $res:expr) => {
_= $context.send_str($res).await;
};
($context:ident json -> $res:expr) => {
let mut sender = $context.sender();
_= sender.send_json($res).await;
};
($context:ident file -> $res:expr) => {
let mut sender = $context.sender();
let sending_result= sender.send_file(water_http::http::FileRSender::new($res)).await;
if !sending_result.is_success() {
_= sender.send_status_code(water_http::http::status_code::HttpStatusCode::NOT_FOUND);
}
};
($context:ident download -> $res:expr) => {
let mut sender = $context.sender();
let mut __f = water_http::http::FileRSender::new($res);
__f.set_content_disposition("attachment");
let sending_result= sender.send_file(__f).await;
if !sending_result.is_success() {
_= sender.send_status_code(water_http::http::status_code::HttpStatusCode::NOT_FOUND);
}
};
($context:ident download -> $res:expr , $($function_tokens:tt)*) => {
let mut __sender = $context.sender();
let mut __f = water_http::http::FileRSender::new($res);
__f.set_content_disposition("attachment");
__f.set_edit_each_chunk( $($function_tokens)*);
let sending_result= __sender.send_file(__f).await;
if !sending_result.is_success() {
_= __sender.send_status_code(water_http::http::status_code::HttpStatusCode::INTERNAL_SERVER_ERROR);
}
};
($context:ident file -> $res:expr , $($function_tokens:tt)*) => {
let mut __sender = $context.sender();
let mut __f = water_http::http::FileRSender::new($res);
__f.set_edit_each_chunk( $($function_tokens)*);
let sending_result= __sender.send_file(__f).await;
if !sending_result.is_success() {
_= __sender.send_status_code(water_http::http::status_code::HttpStatusCode::INTERNAL_SERVER_ERROR);
}
};
($context:ident string -> $res:ident) => {
_= $context.send_string_slice(&$res).await;
};
($context:ident string -> &$res:ident) => {
_= $context.send_string_slice(&$res).await;
};
($context:ident string -> $value:expr ) => {
_= $context.send_string_slice(format!($value).as_str()).await;
};
}
#[macro_export]
macro_rules! functions_builder {
{
$($tokens:tt)*
} => {
$crate::hidden_functions_builder!(@parsed[], $($tokens)*);
};
}
#[cfg(feature = "thread_shared_struct")]
#[doc(hidden)]
#[macro_export]
macro_rules! hidden_functions_builder {
(
@parsed[$($d:tt)*],
$fn_name:ident($context:ident $(, $parameter_name:ident : $typ:ty)* ) $async:tt
($($param:ident),*) {
$($body_tokens:tt)*
}
$($res:tt)*
) => {
$crate::hidden_functions_builder! (
@parsed[
$($d)*
],
pub fn $fn_name($context$(,$parameter_name:$typ)*) $async {
$(let $param = $context.get_from_path_params(stringify!($param)).unwrap();)*
$($body_tokens)*
}
$($res)*
);
};
(
@parsed[$($d:tt)*],
$pub:tt $fn:tt $fn_name:ident($context:ident $(, $parameter_name:ident : $typ:ty)* ) $async:tt
($($param:ident),*) {
$($body_tokens:tt)*
}
$($res:tt)*
) => {
$crate::hidden_functions_builder! (
@parsed[
$($d)*
],
$pub $fn $fn_name($context$(,$parameter_name:$typ)*) $async {
$(let $param = $context.get_from_path_params(stringify!($param)).unwrap();)*
$($body_tokens)*
}
$($res)*
);
};
(
@parsed[$($d:tt)*],
pub $fn:tt $fn_name:ident($context:ident $(, $parameter_name:ident : $typ:ty)* )
($($param:ident),*) {
$($body_tokens:tt)*
}
$($res:tt)*
) => {
$crate::hidden_functions_builder! (
@parsed[
$($d)*
],
pub $fn $fn_name($context$(,$parameter_name:$typ)*) async {
$(let $param = $context.get_from_path_params(stringify!($param)).unwrap();)*
$($body_tokens)*
}
$($res)*
);
};
(
@parsed[$($d:tt)*],
$pub:tt $async:tt $fn:tt $fn_name:ident($context:ident $(, $parameter_name:ident : $typ:ty)* )
($($param:ident),*) {
$($body_tokens:tt)*
}
$($res:tt)*
) => {
$crate::hidden_functions_builder! (
@parsed[
$($d)*
],
$pub $fn $fn_name($context$(,$parameter_name:$typ)*) $async {
$(let $param = $context.get_from_path_params(stringify!($param)).unwrap();)*
$($body_tokens)*
}
$($res)*
);
};
(
@parsed[$($d:tt)*],
$pub:tt $async:tt $fn:tt $fn_name:ident($context:ident $(, $parameter_name:ident : $typ:ty)* )
{
$($body_tokens:tt)*
}
$($res:tt)*
) => {
$crate::hidden_functions_builder! (
@parsed[
$($d)*
],
$pub $fn $fn_name($context$(,$parameter_name:$typ)*) $async {
$($body_tokens)*
}
$($res)*
);
};
(
@parsed[$($d:tt)*],
$async:tt $fn:tt $fn_name:ident($context:ident $(, $parameter_name:ident : $typ:ty)* )
($($param:ident),*) {
$($body_tokens:tt)*
}
$($res:tt)*
) => {
$crate::hidden_functions_builder! (
@parsed[
$($d)*
],
pub $fn $fn_name($context$(,$parameter_name:$typ)*) $async {
$(let $param = $context.get_from_path_params(stringify!($param)).unwrap();)*
$($body_tokens)*
}
$($res)*
);
};
(
@parsed[$($d:tt)*],
$async:tt $fn:tt $fn_name:ident($context:ident $(, $parameter_name:ident : $typ:ty)* )
{
$($body_tokens:tt)*
}
$($res:tt)*
) => {
$crate::hidden_functions_builder! (
@parsed[
$($d)*
],
pub $fn $fn_name($context$(,$parameter_name:$typ)*) $async {
$($body_tokens)*
}
$($res)*
);
};
(
@parsed[$($d:tt)*],
$fn:tt $fn_name:ident($context:ident $(, $parameter_name:ident : $typ:ty)* )
($($param:ident),*) {
$($body_tokens:tt)*
}
$($res:tt)*
) => {
$crate::hidden_functions_builder! (
@parsed[
$($d)*
],
pub $fn $fn_name($context$(,$parameter_name:$typ)*) async {
$(let $param = $context.get_from_path_params(stringify!($param)).unwrap();)*
$($body_tokens)*
}
$($res)*
);
};
(
@parsed[$($d:tt)*],
$fn:tt $fn_name:ident($context:ident $(, $parameter_name:ident : $typ:ty)* )
{
$($body_tokens:tt)*
}
$($res:tt)*
) => {
$crate::hidden_functions_builder! (
@parsed[
$($d)*
],
pub $fn $fn_name($context$(,$parameter_name:$typ)*) async {
$($body_tokens)*
}
$($res)*
);
};
(
@parsed[$($d:tt)*],
$pub:tt $fn:tt $fn_name:ident($context:ident $(, $parameter_name:ident : $typ:ty)* ) $async:tt {
$($body_tokens:tt)*
}
$($res:tt)*
) => {
$crate::hidden_functions_builder! (
@parsed[
$($d)*
$pub $async $fn $fn_name<
'context,
MainHolderType: Send + 'static,
#[cfg(feature = "use_tokio_send")]
Shared:Clone + Send + 'static,
#[cfg(not(feature = "use_tokio_send"))]
Shared:Clone ,
const header_length: usize,
const query_length: usize
>(
$context: &mut $crate::server::HttpContext<
'context,
MainHolderType,
Shared,
header_length,
query_length
>
$(, $parameter_name: $typ)*
) {
$($body_tokens)*
}
],
$($res)*
);
};
(@parsed[$($d:tt)*],) => {
$($d)*
};
}
#[cfg(not(feature = "thread_shared_struct"))]
#[doc(hidden)]
#[macro_export]
macro_rules! hidden_functions_builder {
(
@parsed[$($d:tt)*],
$fn_name:ident($context:ident $(, $parameter_name:ident : $typ:ty)* ) $async:tt
($($param:ident),*) {
$($body_tokens:tt)*
}
$($res:tt)*
) => {
$crate::hidden_functions_builder! (
@parsed[
$($d)*
],
pub fn $fn_name($context$(,$parameter_name:$typ)*) $async {
$(let $param = $context.get_from_path_params(stringify!($param)).unwrap();)*
$($body_tokens)*
}
$($res)*
);
};
(
@parsed[$($d:tt)*],
$pub:tt $fn:tt $fn_name:ident($context:ident $(, $parameter_name:ident : $typ:ty)* ) $async:tt
($($param:ident),*) {
$($body_tokens:tt)*
}
$($res:tt)*
) => {
$crate::hidden_functions_builder! (
@parsed[
$($d)*
],
$pub $fn $fn_name($context$(,$parameter_name:$typ)*) $async {
$(let $param = $context.get_from_path_params(stringify!($param)).unwrap();)*
$($body_tokens)*
}
$($res)*
);
};
(
@parsed[$($d:tt)*],
pub $fn:tt $fn_name:ident($context:ident $(, $parameter_name:ident : $typ:ty)* )
($($param:ident),*) {
$($body_tokens:tt)*
}
$($res:tt)*
) => {
$crate::hidden_functions_builder! (
@parsed[
$($d)*
],
pub $fn $fn_name($context$(,$parameter_name:$typ)*) async {
$(let $param = $context.get_from_path_params(stringify!($param)).unwrap();)*
$($body_tokens)*
}
$($res)*
);
};
(
@parsed[$($d:tt)*],
$pub:tt $async:tt $fn:tt $fn_name:ident($context:ident $(, $parameter_name:ident : $typ:ty)* )
($($param:ident),*) {
$($body_tokens:tt)*
}
$($res:tt)*
) => {
$crate::hidden_functions_builder! (
@parsed[
$($d)*
],
$pub $fn $fn_name($context$(,$parameter_name:$typ)*) $async {
$(let $param = $context.get_from_path_params(stringify!($param)).unwrap();)*
$($body_tokens)*
}
$($res)*
);
};
(
@parsed[$($d:tt)*],
$pub:tt $async:tt $fn:tt $fn_name:ident($context:ident $(, $parameter_name:ident : $typ:ty)* )
{
$($body_tokens:tt)*
}
$($res:tt)*
) => {
$crate::hidden_functions_builder! (
@parsed[
$($d)*
],
$pub $fn $fn_name($context$(,$parameter_name:$typ)*) $async {
$($body_tokens)*
}
$($res)*
);
};
(
@parsed[$($d:tt)*],
$async:tt $fn:tt $fn_name:ident($context:ident $(, $parameter_name:ident : $typ:ty)* )
($($param:ident),*) {
$($body_tokens:tt)*
}
$($res:tt)*
) => {
$crate::hidden_functions_builder! (
@parsed[
$($d)*
],
pub $fn $fn_name($context$(,$parameter_name:$typ)*) $async {
$(let $param = $context.get_from_path_params(stringify!($param)).unwrap();)*
$($body_tokens)*
}
$($res)*
);
};
(
@parsed[$($d:tt)*],
$async:tt $fn:tt $fn_name:ident($context:ident $(, $parameter_name:ident : $typ:ty)* )
{
$($body_tokens:tt)*
}
$($res:tt)*
) => {
$crate::hidden_functions_builder! (
@parsed[
$($d)*
],
pub $fn $fn_name($context$(,$parameter_name:$typ)*) $async {
$($body_tokens)*
}
$($res)*
);
};
(
@parsed[$($d:tt)*],
$fn:tt $fn_name:ident($context:ident $(, $parameter_name:ident : $typ:ty)* )
($($param:ident),*) {
$($body_tokens:tt)*
}
$($res:tt)*
) => {
$crate::hidden_functions_builder! (
@parsed[
$($d)*
],
pub $fn $fn_name($context$(,$parameter_name:$typ)*) async {
$(let $param = $context.get_from_path_params(stringify!($param)).unwrap();)*
$($body_tokens)*
}
$($res)*
);
};
(
@parsed[$($d:tt)*],
$fn:tt $fn_name:ident($context:ident $(, $parameter_name:ident : $typ:ty)* )
{
$($body_tokens:tt)*
}
$($res:tt)*
) => {
$crate::hidden_functions_builder! (
@parsed[
$($d)*
],
pub $fn $fn_name($context$(,$parameter_name:$typ)*) async {
$($body_tokens)*
}
$($res)*
);
};
(
@parsed[$($d:tt)*],
$pub:tt $fn:tt $fn_name:ident($context:ident $(, $parameter_name:ident : $typ:ty)* ) $async:tt {
$($body_tokens:tt)*
}
$($res:tt)*
) => {
$crate::hidden_functions_builder! (
@parsed[
$($d)*
$pub $async $fn $fn_name<
'context,
MainHolderType: Send + 'static,
const header_length: usize,
const query_length: usize
>(
$context: &mut $crate::server::HttpContext<
'context,
MainHolderType,
header_length,query_length
>
$(, $parameter_name: $typ)*
) {
$($body_tokens)*
}
],
$($res)*
);
};
(@parsed[$($d:tt)*],) => {
$($d)*
};
}