Skip to content

Parsing request body mulitple times behaves oddly. #3

Closed
@mf59816

Description

@mf59816

Consider the routing table:

type Routes =
  ...
  :<|> ReqBody User :> Post UserID
  :<|> Capture "userid" UserID :> ReqBody User :> Put ()
  ...

The first route fails for Put requests, but the second will find that
the request body has already been parsed, and will complain about ""
not being a parseable json representation of User.

The work-around is simple:

type Routes =
  ...
  :<|> Capture "userid" UserID :> ReqBody User :> Put ()
  :<|> ReqBody User :> Post UserID
  ...

But I'm not sure it is that simple in all cases, or that obvious to
understand the situation once you've stumbled into this trap.

We have some (limited) resources to work on a solution, but we would
like to hear what you think first.

Servant is AWwesome, btw. Thanks for writing it! (:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions