1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//! A filter that matches any route.
use Infallible;
use Future;
use Pin;
use ;
use crate;
/// A [`Filter`](crate::Filter) that matches any route.
///
/// This can be a useful building block to build new filters from,
/// since [`Filter`] is otherwise a sealed trait.
///
/// # Example
///
/// ```
/// use starterm::Filter;
///
/// let route = starterm::any()
/// .map(|| {
/// "I always return this string!"
/// });
/// ```
///
/// This could allow creating a single `impl Filter` returning a specific
/// reply, that can then be used as the end of several different filter
/// chains.
///
/// Another use case is turning some clone-able resource into a `Filter`,
/// thus allowing to easily `and` it together with others.
///
/// ```
/// use std::sync::Arc;
/// use starterm::Filter;
///
/// let state = Arc::new(vec![33, 41]);
/// let with_state = starterm::any().map(move || state.clone());
///
/// // Now we could `and` with any other filter:
///
/// let route = starterm::path::param()
/// .and(with_state)
/// .map(|param_id: u32, db: Arc<Vec<u32>>| {
/// db.contains(¶m_id)
/// });
/// ```
+ Copy
;
;