Skip to content

DecodableRequest

Josh Wright edited this page Jan 14, 2021 · 3 revisions

DecodableRequest

A type from which a RequestAllowed can be decoded. Conform your server's Request type to this for easy validation against a RequestAllowed type.

public protocol DecodableRequest

Requirements

header(for:​)

Get a header for a given key.

func header(for key: String) -> String?

Parameters

  • key: The key of the header.

Returns

The value of the header for the given key, if it exists.

query(for:​)

Get a url query value for a given key.

func query(for key: String) -> String?

Parameters

  • key: The key of the query.

Returns

The value of the query for the given key, if it exists.

pathComponent(for:​)

Get a path component for a given key.

func pathComponent(for key: String) -> String?

Parameters

  • key: The key of the path component.

Returns

The value of the path component for the given key, if it exists.

decodeBody(encoding:​)

Decode the body of a request as JSON.

func decodeBody<T: Decodable>(encoding: BodyEncoding) throws -> T

Throws

Any error thrown decoding the request body to T.

Returns

An instance of T, decoded from this request's body.

Alchemy
Types
Protocols
Global Typealiases
Global Variables
Global Functions
Fusion
Types
Protocols
Papyrus
Types
Protocols
Clone this wiki locally