Skip to content

Commit 28d32e9

Browse files
authored
Add Body() parser (#205)
* Add `Body()` parser * wip * wip
1 parent df6a89a commit 28d32e9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Sources/_URLRouting/Body.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public struct Body<Bytes: Parser>: Parser where Bytes.Input == Data {
2020
/// var message: String
2121
/// }
2222
///
23-
/// Body(.data.json(Comment.self))
23+
/// Body(.json(Comment.self))
2424
/// ```
2525
///
2626
/// - Parameter bytesConversion: A conversion that transforms bytes into some other type.
@@ -30,6 +30,12 @@ public struct Body<Bytes: Parser>: Parser where Bytes.Input == Data {
3030
self.bytesParser = Rest().replaceError(with: .init()).map(bytesConversion)
3131
}
3232

33+
/// Initializes a body parser that parses the body as data in its entirety.
34+
@inlinable
35+
public init() where Bytes == Parsers.ReplaceError<Rest<Bytes.Input>> {
36+
self.bytesParser = Rest().replaceError(with: .init())
37+
}
38+
3339
@inlinable
3440
public func parse(_ input: inout URLRequestData) throws -> Bytes.Output {
3541
guard var body = input.body

0 commit comments

Comments
 (0)