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 module that handles and provides easy to use macros for the user.
/// A quick way to create responses.
///
/// Usage:
/// ```
/// use snowboard::{response, HttpVersion, headers};
/// use std::collections::HashMap;
///
/// // Response with no headers and no body.
/// let response = response!(bad_request);
///
/// // Response with body and no headers.
/// // Note that $body requires to implement `Into<Vec<u8>>`.
/// let response = response!(internal_server_error, "oopsies");
///
/// // Response with body, headers and custom HTTP version.
/// let body = "everything's fine!";
/// let headers = headers! {
/// "Content-Type" => "text/html",
/// "X-Hello" => "World!",
/// "X-Number" => 42,
/// };
/// let response = response!(ok, body, headers, HttpVersion::V1_0);
/// ```
///
/// See [headers!](crate::headers) for more information about the headers macro.
/// A quick way to create a header HashMap.
///
/// A similar version of this macro can be found in other
/// crates as `map!` or `hashmap!`.
///
/// This will convert any `$value` to a String, since
/// the headers are stored as `HashMap<&str, String>`.
///
/// Example:
/// ```rust
/// use snowboard::headers;
///
/// let headers = headers! {
/// "Content-Type" => "text/html",
/// "X-Hello" => "World!",
/// "X-Number" => 42,
/// };
/// ```
};
}