Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ extern crate sequence_trie;
pub use mount::{Mount, OriginalUrl};

mod mount;

mod macros;
24 changes: 24 additions & 0 deletions src/macros.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/// Create a set of mounts.
///
/// E.g. if you had a directory to serve images from:
///
/// ```ignore
/// let mount = mount!("/images" => handler_for_image_dir);
/// ```
///
/// Is equivalent to:
///
/// ```ignore
/// let mut mount = Mount::new();
/// mount.mount("/images", handler_for_image_dir);
/// ```
///
/// You may provide multiple mappings, comma-delimited.
#[macro_export]
macro_rules! mount {
($($path:expr => $handler:expr),+ $(,)*) => ({
let mut mount = $crate::Mount::new();
$(mount.mount($path, $handler);)*
mount
});
}