HomePhorge

Cast and validate body_params separately

Description

Cast and validate body_params separately

This change is motivated by the unintuitive behaviour of
merging the cast request body with the query/path params
into a single struct.

Matching on such a struct produces a compile error.

Since Plug.Conn already has a field to store body_params,
we use that to hold the cast requestBody.

matching on the requestBody in a controller now requires:

def create(conn = %{body_params: %SomeType{}}, other_params: %{}) do
...
end

Details

Provenance
Michael BuhotAuthored on Aug 13 2018, 4:51 AM
Parents
R22:6535c742bd3a: Prepare version 2.3.0
Branches
Unknown
Tags
Unknown

Event Timeline