diff options
author | Martin Fischer <martin@push-f.com> | 2021-01-29 11:38:33 +0100 |
---|---|---|
committer | Martin Fischer <martin@push-f.com> | 2021-01-29 11:38:57 +0100 |
commit | 10b5cd07f07cefd15450001375cd1c3e6927cc8a (patch) | |
tree | 8bd05662b4eacb54f6537c18788a33f861714fc3 /src/response.rs | |
parent | 6c44846f6bf5901eaa12b943646632bd2163c898 (diff) |
add documentation
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>>; |