Add expectBody.

This commit is contained in:
Dillon Kearns 2022-03-08 16:10:02 -08:00
parent 661c84467b
commit 3e4643f598
2 changed files with 20 additions and 7 deletions

File diff suppressed because one or more lines are too long

View File

@ -9,8 +9,9 @@ module Server.Request exposing
, expectQueryParam
, cookie, expectCookie
, expectHeader
, expectFormPost
, File, expectMultiPartFormPost
, expectBody
, expectFormPost
, map3, map4, map5, map6, map7, map8, map9
, errorsToString, errorToString, getDecoder, ValidationError
)
@ -53,16 +54,17 @@ module Server.Request exposing
@docs expectHeader
## Form Posts
@docs expectFormPost
## Multi-part forms and file uploads
@docs File, expectMultiPartFormPost
## Request Parsers That Can Fail
@docs expectBody
@docs expectFormPost
## Map Functions
@docs map3, map4, map5, map6, map7, map8, map9
@ -999,6 +1001,17 @@ rawBody =
|> Parser
{-| Same as [`rawBody`](#rawBody), but will only match when a body is present in the HTTP request.
-}
expectBody : Parser String
expectBody =
rawBody
|> andThen
(Result.fromMaybe "Expected body but none was present."
>> fromResult
)
{-| -}
type Method
= Connect