Skip to content

You're viewing documentation for a pre-release version. View the latest stable version

Instance Method

decode(_:as:)

Use the default configured decoder for the contentType parameter to read a value of type C from the container.
func decode<C>(_: C.Type, as contentType: HTTPMediaType) async throws -> C where C : Content

Discussion

This overload exists so that passing an explicit content type still runs afterDecode(). Without it a Content type binds to the Decodable overload above, which cannot know to call the hook, and the type is silently returned unprocessed.

Note

The defaultContentType of C is ignored.