refactor(headers): Introduce header!() macro, improve documentation
The new macro handles single value headers, list headers, and list headers with at least one item. It creates the item for the header and contains its documentation. The new macro allows handling more header cases in the future, it will also be possible to include tests inside the macro. BREAKING CHANGE: Removed impl_header!() and impl_list_header!() macros, use new header!() macro.
This commit is contained in:
@@ -1,19 +1,19 @@
|
||||
/// The `Location` header.
|
||||
///
|
||||
/// The Location response-header field is used to redirect the recipient to
|
||||
/// a location other than the Request-URI for completion of the request or identification
|
||||
/// of a new resource. For 201 (Created) responses, the Location is that of the new
|
||||
/// resource which was created by the request. For 3xx responses, the location SHOULD
|
||||
/// indicate the server's preferred URI for automatic redirection to the resource.
|
||||
/// The field value consists of a single absolute URI.
|
||||
///
|
||||
/// Currently is just a String, but it should probably become a better type,
|
||||
/// like url::Url or something.
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct Location(pub String);
|
||||
header! {
|
||||
#[doc="`Location` header, defined in"]
|
||||
#[doc="[RFC7231](http://tools.ietf.org/html/rfc7231#section-7.1.2)"]
|
||||
#[doc=""]
|
||||
#[doc="The `Location` header field is used in some responses to refer to a"]
|
||||
#[doc="specific resource in relation to the response. The type of"]
|
||||
#[doc="relationship is defined by the combination of request method and"]
|
||||
#[doc="status code semantics."]
|
||||
#[doc=""]
|
||||
#[doc="# ABNF"]
|
||||
#[doc="```plain"]
|
||||
#[doc="Location = URI-reference"]
|
||||
#[doc="```"]
|
||||
// TODO: Use URL
|
||||
(Location, "Location") => [String]
|
||||
|
||||
impl_header!(Location,
|
||||
"Location",
|
||||
String);
|
||||
}
|
||||
|
||||
bench_header!(bench, Location, { vec![b"http://foo.com/hello:3000".to_vec()] });
|
||||
|
||||
Reference in New Issue
Block a user