aboutsummaryrefslogtreecommitdiff
path: root/src/response
diff options
context:
space:
mode:
authorFuwn <[email protected]>2023-04-02 01:57:26 +0000
committerFuwn <[email protected]>2023-04-02 01:57:26 +0000
commit5e6ea230ab98f4a2761876ebe1646c13588e36b1 (patch)
tree1eb43a5723483c4fb13f25951a61a703989ed1b1 /src/response
parentfeat(respones): accept generic bytes for binary_success (diff)
downloadwindmark-5e6ea230ab98f4a2761876ebe1646c13588e36b1.tar.xz
windmark-5e6ea230ab98f4a2761876ebe1646c13588e36b1.zip
feat(response): add 'auto' functionality to binary_success raw
Diffstat (limited to 'src/response')
-rw-r--r--src/response/macros.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/response/macros.rs b/src/response/macros.rs
index e04b0ee..f49da2d 100644
--- a/src/response/macros.rs
+++ b/src/response/macros.rs
@@ -61,9 +61,41 @@ macro_rules! binary_success {
::windmark::Response::binary_success($body, $mime)
})
};
+ ($body:expr) => {{
+ #[cfg(not(feature = "auto-deduce-mime"))]
+ compile_error!(
+ "`binary_success` without a MIME type requires the `auto-deduce-mime` \
+ feature to be enabled"
+ );
+
+ ::std::boxed::Box::new(|_| {
+ #[cfg(feature = "auto-deduce-mime")]
+ return ::windmark::Response::binary_success_auto($body);
+
+ // Suppress item not found warning
+ #[cfg(not(feature = "auto-deduce-mime"))]
+ ::windmark::Response::binary_success($body, "application/octet-stream")
+ })
+ }};
($context:ident, $body:expr, $mime:expr) => {
::std::boxed::Box::new(|$context| {
::windmark::Response::binary_success($body, $mime)
})
};
+ ($context:ident, $body:expr) => {{
+ #[cfg(not(feature = "auto-deduce-mime"))]
+ compile_error!(
+ "`binary_success` without a MIME type requires the `auto-deduce-mime` \
+ feature to be enabled"
+ );
+
+ ::std::boxed::Box::new(|$context| {
+ #[cfg(feature = "auto-deduce-mime")]
+ return ::windmark::Response::binary_success_auto($body);
+
+ // Suppress item not found warning
+ #[cfg(not(feature = "auto-deduce-mime"))]
+ ::windmark::Response::binary_success($body, "application/octet-stream")
+ })
+ }};
}