diff options
author | metamuffin <metamuffin@disroot.org> | 2023-02-11 10:29:02 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2023-02-11 10:29:02 +0100 |
commit | 9dfc929b709d4187dc307f68a42fa058eda7a4c1 (patch) | |
tree | d9c56d3a2ccabd7183d539f3b2b349be62530aad /server/src/assets.rs | |
parent | 89f9f9e1c3a29ba16d53227786dfba18587f9fa7 (diff) | |
download | keks-meet-9dfc929b709d4187dc307f68a42fa058eda7a4c1.tar keks-meet-9dfc929b709d4187dc307f68a42fa058eda7a4c1.tar.bz2 keks-meet-9dfc929b709d4187dc307f68a42fa058eda7a4c1.tar.zst |
standalone binary
Diffstat (limited to 'server/src/assets.rs')
-rw-r--r-- | server/src/assets.rs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/server/src/assets.rs b/server/src/assets.rs new file mode 100644 index 0000000..068bc0c --- /dev/null +++ b/server/src/assets.rs @@ -0,0 +1,37 @@ +#[cfg(not(feature = "standalone"))] +#[macro_export] +macro_rules! s_file { + ($path: literal) => { + warp::fs::file($path) + }; +} + +#[cfg(not(feature = "standalone"))] +#[macro_export] +macro_rules! s_asset_dir { + () => { + warp::fs::dir("client-web/public/assets") + }; +} + +#[cfg(feature = "standalone")] +#[macro_export] +macro_rules! s_file { + ($path: literal) => { + warp::get().map(|| include_str!(concat!("../../", $path))) + }; +} + +#[cfg(feature = "standalone")] +#[macro_export] +macro_rules! s_asset_dir { + () => {{ + use include_dir::{include_dir, Dir}; + const DIR: Dir = include_dir!("$CARGO_MANIFEST_DIR/../client-web/public/assets"); + warp::path::tail().and_then(|t: warp::path::Tail| async move { + DIR.get_file(t.as_str()) + .map(|f| f.contents_utf8().unwrap()) + .ok_or(warp::reject::not_found()) + }) + }}; +} |