diff options
Diffstat (limited to 'src/response.rs')
-rw-r--r-- | src/response.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/response.rs b/src/response.rs index c8ff23a..2d5d469 100644 --- a/src/response.rs +++ b/src/response.rs @@ -1,4 +1,4 @@ -//! Provides the [`SputnikBuilder`] trait. +//! Provides convenience traits and functions to build HTTP responses. use std::convert::TryInto; @@ -7,6 +7,7 @@ use hyper::{HeaderMap, StatusCode, header, http}; use time::{Duration, OffsetDateTime}; use hyper::http::response::Builder; +/// Adds convenience methods to [`Builder`]. pub trait SputnikBuilder { /// Sets the Content-Type. fn content_type(self, mime: mime::Mime) -> Builder; @@ -15,6 +16,7 @@ pub trait SputnikBuilder { fn set_cookie(self, cookie: Cookie) -> Builder; } +/// Creates a new builder with a given Location header and status code. pub fn redirect(location: &str, code: StatusCode) -> Builder { Builder::new().status(code).header(header::LOCATION, location) } @@ -39,6 +41,7 @@ pub fn delete_cookie(name: &str) -> Cookie { cookie } +/// Adds convenience methods to [`HeaderMap`]. pub trait SputnikHeaders { /// Sets the Content-Type. fn content_type(&mut self, mime: mime::Mime); @@ -57,6 +60,7 @@ impl SputnikHeaders for HeaderMap { } } +/// Adds a convenience method to consume a [`Builder`] with an empty body. pub trait EmptyBuilder<B> { /// Consume the builder with an empty body. fn empty(self) -> http::Result<http::response::Response<B>>; |