Skip to content

Commit

Permalink
Improve documentation for PayloadConfig (#1923)
Browse files Browse the repository at this point in the history
  • Loading branch information
jplatte authored Jan 24, 2021
1 parent 0c8196f commit c201c15
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/types/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,22 +191,25 @@ fn bytes_to_string(body: Bytes, encoding: &'static Encoding) -> Result<String, E
/// building extractors on top of `Payload`.
///
/// By default, the payload size limit is 256kB and there is no mime type condition.
///
/// To use this, add an instance of it to your app or service through one of the
/// `.app_data()` methods.

This comment has been minimized.

Copy link
@omid

omid Jan 30, 2021

Contributor

I suggest adding an example, instead of just naming the method.

#[derive(Clone)]
pub struct PayloadConfig {
limit: usize,
mimetype: Option<Mime>,
}

impl PayloadConfig {
/// Create new instance with a size limit and no mime type condition.
/// Create new instance with a size limit (in bytes) and no mime type condition.
pub fn new(limit: usize) -> Self {
Self {
limit,
..Default::default()
}
}

/// Set maximum accepted payload size. The default limit is 256kB.
/// Set maximum accepted payload size in bytes. The default limit is 256kB.

This comment has been minimized.

Copy link
@omid

omid Jan 30, 2021

Contributor

I think it's also better to change all "kB"s to "KiB"

pub fn limit(mut self, limit: usize) -> Self {
self.limit = limit;
self
Expand Down

0 comments on commit c201c15

Please sign in to comment.