ContentNegotiationConfig

A configuration for the ContentNegotiation plugin.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

Checks that the ContentType header value of a response suits the Accept header value of a request.

Functions

Link copied to clipboard

Registers a custom accepted content types contributor. A contributor function takes io.ktor.server.application.ApplicationCall and a list of content types accepted according to the HttpHeaders.Accept header or provided by the previous contributor if exists. The result of this contributor should be a list of accepted content types with a quality. A contributor could either keep or replace input list of accepted content types depending on a use case. For example, a contributor taking the format=json request parameter could replace the original content types list with the specified one from the uri argument. Note that the returned list of accepted types will be sorted according to the quality using sortedByQuality, so a custom contributor may keep it unsorted and should not rely on input list order.

Link copied to clipboard

Clear all configured ignored types including defaults.

Link copied to clipboard
inline fun <T> ignoreType()

Adds a type to the list of types that should be ignored by ContentNegotiation.

fun ignoreType(type: KClass<*>)

Adds a type to the list of types that should be ignored by ContentNegotiation.

Link copied to clipboard
open override fun <T : ContentConverter> register(contentType: ContentType, converter: T, configuration: T.() -> Unit)

Registers a contentType to a specified converter with an optional converter configuration.

Link copied to clipboard
inline fun <T> removeIgnoredType()

Remove T from the list of types that should be ignored by ContentNegotiation.

Remove type from the list of types that should be ignored by ContentNegotiation.