-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0e1b207
commit d7711c4
Showing
28 changed files
with
1,551 additions
and
7 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
doc_examples/guide/request_data/buffered_body/project-custom_limit.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
```rust title="src/custom_limit/blueprint.rs" | ||
use pavex::blueprint::{constructor::Lifecycle, Blueprint}; | ||
use pavex::f; | ||
use pavex::request::body::BodySizeLimit; | ||
pub fn body_size_limit() -> BodySizeLimit { | ||
BodySizeLimit::Enabled { | ||
max_n_bytes: 10_485_760, // 10 MBs | ||
} | ||
} | ||
pub fn blueprint() -> Blueprint { | ||
let mut bp = Blueprint::new(); | ||
bp.constructor(f!(crate::body_size_limit), Lifecycle::Singleton); | ||
// [...] | ||
} | ||
``` |
9 changes: 9 additions & 0 deletions
9
doc_examples/guide/request_data/buffered_body/project-extraction.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
```rust title="src/buffered_body/routes.rs" hl_lines="4" | ||
use pavex::http::StatusCode; | ||
use pavex::request::body::BufferedBody; | ||
pub fn handler(body: &BufferedBody) -> StatusCode { | ||
format!("The incoming request contains {} bytes", body.bytes.len()); | ||
// [...] | ||
} | ||
``` |
27 changes: 27 additions & 0 deletions
27
doc_examples/guide/request_data/buffered_body/project-granular_limits.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
```rust title="src/granular_limits/blueprint.rs" | ||
use pavex::blueprint::{constructor::Lifecycle, router::POST, Blueprint}; | ||
use pavex::f; | ||
use pavex::request::body::BodySizeLimit; | ||
pub fn blueprint() -> Blueprint { | ||
let mut bp = Blueprint::new(); | ||
bp.nest(upload_bp()); | ||
// Other routes... | ||
bp | ||
} | ||
fn upload_bp() -> Blueprint { | ||
let mut bp = Blueprint::new(); | ||
// This limit will only apply to the routes registered | ||
// in this nested blueprint. | ||
bp.constructor(f!(crate::upload_size_limit), Lifecycle::Singleton); | ||
bp.route(POST, "/upload", f!(crate::upload)); | ||
bp | ||
} | ||
pub fn upload_size_limit() -> BodySizeLimit { | ||
BodySizeLimit::Enabled { | ||
max_n_bytes: 1_073_741_824, // 1GB | ||
} | ||
} | ||
``` |
15 changes: 15 additions & 0 deletions
15
doc_examples/guide/request_data/buffered_body/project-no_limit.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
```rust title="src/no_limit/blueprint.rs" | ||
use pavex::blueprint::{constructor::Lifecycle, Blueprint}; | ||
use pavex::f; | ||
use pavex::request::body::BodySizeLimit; | ||
pub fn body_size_limit() -> BodySizeLimit { | ||
BodySizeLimit::Disabled | ||
} | ||
pub fn blueprint() -> Blueprint { | ||
let mut bp = Blueprint::new(); | ||
bp.constructor(f!(crate::body_size_limit), Lifecycle::Singleton); | ||
// [...] | ||
} | ||
``` |
1 change: 1 addition & 0 deletions
1
doc_examples/guide/request_data/buffered_body/project/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/target |
Oops, something went wrong.