argan/http.rs
1//! Fundamental HTTP types.
2
3pub use argan_core::http::*;
4
5use crate::common::{marker::Sealed, IntoArray};
6
7// --------------------------------------------------------------------------------
8// --------------------------------------------------------------------------------
9
10// --------------------------------------------------
11// Method
12
13impl IntoArray<Method, 1> for Method {
14 fn into_array(self) -> [Method; 1] {
15 [self]
16 }
17}
18
19impl Sealed for Method {}
20
21// --------------------------------------------------
22// CustomMethod
23
24/// A type that represents a *custom HTTP method*.
25///
26/// ```
27/// use argan::{Resource, http::CustomMethod};
28///
29/// let mut resource = Resource::new("/");
30/// resource.set_handler_for(CustomMethod("LOCK").to(|| async { /* ... */ }));
31/// ```
32pub struct CustomMethod<M>(pub M);
33
34// --------------------------------------------------
35// WildcardMethod
36
37/// A type that represents a *wildcard method*.
38///
39/// ```
40/// use argan::{Resource, http::WildcardMethod};
41///
42/// let mut resource = Resource::new("/");
43/// resource.set_handler_for(WildcardMethod.to(Some(|| async { /* ... */ })));
44/// ```
45pub struct WildcardMethod;
46
47// --------------------------------------------------