Package-level declarations

Types

Link copied to clipboard

A spec for configuring an AdapterCodec.

Link copied to clipboard

A spec for configuring a Request, excluding the request method and body.

Link copied to clipboard
typealias BodyHandler<T> = <Error class: unknown class><T>
Link copied to clipboard
typealias BodyHandlers = <Error class: unknown class>
Link copied to clipboard
typealias BodyPublisher = <Error class: unknown class>
Link copied to clipboard
typealias BodyPublishers = <Error class: unknown class>
Link copied to clipboard
typealias BodySubscriber<T> = <Error class: unknown class><T>
Link copied to clipboard
typealias BodySubscribers = <Error class: unknown class>
Link copied to clipboard
typealias Cache = HttpCache
Link copied to clipboard
typealias CacheChain = List<Cache>

A series of caches invoked sequentially during an HTTP call.

Link copied to clipboard

A spec for configuring a CacheChain.

Link copied to clipboard

A spec for configuring CacheControl instances.

Link copied to clipboard
Link copied to clipboard
interface CacheSpec

A spec for configuring a Cache.

Link copied to clipboard
typealias Client = Methanol
Link copied to clipboard
interface ClientSpec

A spec for configuring a Client.

Link copied to clipboard
interface FactorySpec<T>

A Spec that creates an object of type T, typically after invoking a spec configuration block.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
typealias Headers = <Error class: unknown class>
Link copied to clipboard
Link copied to clipboard

A spec for configuring the hints passed to the encoder and/or decoder.

Link copied to clipboard
typealias HttpVersion = <Error class: unknown class>
Link copied to clipboard
interface Interceptor

An object that intercepts requests before being sent and responses before being returned. The intercept function is a suspending function, meaning it is invoked as a coroutine. The coroutine shares the kotlin.coroutines.CoroutineContext used when the HTTP call is first initiated. Typically, this means that all interceptors, along with the HTTP call, are invoked within the same CoroutineScope, and thus typically the same parent kotlinx.coroutines.Job.

Link copied to clipboard

A spec for adding interceptors to a client.

Link copied to clipboard
Placeholder to generate skeletal Javadoc for this Kotlin project.
Link copied to clipboard

A BodyAdapter that uses the serialization package for encoding or decoding Kotlin objects using any format represented by SerialFormat. The given SerialFormat is expected to be a StringFormat or a BinaryFormat, with a preference for the former if both.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

A Spec in the context of which Kotlin's kotlin.to is disabled to avoid conflicts with similarly named spec-defined functions.

Link copied to clipboard
typealias PushPromiseHandler<T> = <Error class: unknown class><T>
Link copied to clipboard
typealias Redirect = <Error class: unknown class>
Link copied to clipboard
typealias Request = <Error class: unknown class>
Link copied to clipboard

A spec for configuring a Request's body assuming its method has been set.

Link copied to clipboard

A spec for configuring a Request's method and body.

Link copied to clipboard
Link copied to clipboard

A spec for configuring a Request whose method has been set

Link copied to clipboard
typealias Response<T> = <Error class: unknown class><T>
Link copied to clipboard
typealias ResponseInfo = <Error class: unknown class>
Link copied to clipboard
annotation class Spec

Marks a type as a specification for configuring some object or property, typically by invoking a user-provided block with the spec as its receiver.

Link copied to clipboard

A Spec for configuring map-like properties with string keys and multi string values.

Link copied to clipboard

A spec for configuring request tags.

Functions

Link copied to clipboard

Creates a new com.github.mizosoft.methanol.AdapterCodec as configured by the given spec block.

Link copied to clipboard
inline fun <T> RequestBodySpec.body(payload: T, mediaType: MediaType)
Link copied to clipboard
fun Cache(block: CacheSpec.() -> Unit): HttpCache

Creates a new com.github.mizosoft.methanol.kotlin.Cache as configured by the given spec block.

Link copied to clipboard

Creates a new com.github.mizosoft.methanol.kotlin.CacheChain as configured by the given spec block.

Link copied to clipboard

Creates a new CacheControl as configured by the given spec block.

Link copied to clipboard
fun Client(block: ClientSpec.() -> Unit): Methanol

Creates a new Client as configured by the given spec block.

Link copied to clipboard

Closes all caches in this chain.

Link copied to clipboard

Returns an AutoCloseable that closes all caches in this chain when invoked.

Link copied to clipboard
inline suspend fun <T> Client.delete(uri: String, noinline block: BaseRequestSpec.() -> Unit = {}): <Error class: unknown class>

Fetches the response to sending a DELETE request to the given URI, mapping the response body into T. A spec block can be optionally passed to customize the request.

suspend fun <T> Client.delete(uri: String, bodyHandler: <Error class: unknown class><T>, block: BaseRequestSpec.() -> Unit = {}): <Error class: unknown class>

Fetches the response to sending a DELETE request to the given URI, mapping the response body with the given BodyHandler. A spec block can be optionally passed to customize the request.

Link copied to clipboard
inline suspend fun <T> Client.fetch(request: <Error class: unknown class>): <Error class: unknown class><T>

Fetches the response to sending the given request, mapping the response body into T.

inline suspend fun <T> Client.fetch(uri: String, noinline block: RequestSpec.() -> Unit = {}): <Error class: unknown class>

Fetches the response to sending a request to the given URI, mapping the response body into T. The request has a GET method by default. A spec block can be optionally passed to customize the request.

suspend fun <T> Client.fetch(uri: String, bodyHandler: <Error class: unknown class><T>, block: RequestSpec.() -> Unit = {}): <Error class: unknown class><T>

Fetches the response sending a request to the given URI, mapping the response body with the given BodyHandler. The request has a GET method by default. A spec block can be optionally passed to customize the request.

Link copied to clipboard

Creates a new FormBody as configured by the given spec block.

Link copied to clipboard
operator fun <Error class: unknown class>.get(name: String): List<String>

Returns all header values associated with the given name.

inline suspend fun <T> Client.get(uri: String, noinline block: BaseRequestSpec.() -> Unit = {}): <Error class: unknown class>

Fetches the response to sending a GET request to the given URI, mapping the response body into T. A spec block can be optionally passed to customize the request.

suspend fun <T> Client.get(uri: String, bodyHandler: <Error class: unknown class><T>, block: BaseRequestSpec.() -> Unit = {}): <Error class: unknown class>

Fetches the response to sending a GET request to the given URI, mapping the response body with the given BodyHandler. A spec block can be optionally passed to customize the request.

Link copied to clipboard
inline fun <T> AdapterCodec.handlerOf(hints: BodyAdapter.Hints = Hints.empty()): <Error class: unknown class><T>

Returns a BodyHandler for the given type.

Link copied to clipboard
fun Headers(block: HeadersSpec.() -> Unit): <Error class: unknown class>

Creates a new Headers as configured by the given spec block.

fun Headers(headers: <Error class: unknown class>, block: HeadersSpec.() -> Unit): <Error class: unknown class>

Creates a copy of the given headers after configuring with the given spec block.

Link copied to clipboard
fun <Error class: unknown class><T>.isClientError(): <Error class: unknown class>

Returns whether this response is 4xx client error.

Link copied to clipboard
fun <Error class: unknown class><T>.isInformational(): <Error class: unknown class>

Returns whether this response is 1xx informational.

Link copied to clipboard
fun <Error class: unknown class><T>.isRedirection(): <Error class: unknown class>

Returns whether this response is 3xx redirection.

Link copied to clipboard
fun <Error class: unknown class><T>.isServerError(): <Error class: unknown class>

Returns whether this response is 5xx server error.

Link copied to clipboard
fun <Error class: unknown class><T>.isSuccessful(): <Error class: unknown class>

Returns whether this response is 2xx successful.

Link copied to clipboard

Creates a new MultipartBody as configured by the given spec block.

Link copied to clipboard
fun MultipartBodyPart(bodyPublisher: <Error class: unknown class>, block: HeadersSpec.() -> Unit): MultipartBodyPart

Creates a new MultipartBodyPart as configured by the given spec block.

Link copied to clipboard
inline suspend fun <T> Client.patch(uri: String, noinline block: RequestWithKnownMethodSpec.() -> Unit = {}): <Error class: unknown class>

Fetches the response to sending a PATCH request to the given URI, mapping the response body into T. A spec block can be optionally passed to customize the request.

suspend fun <T> Client.patch(uri: String, bodyHandler: <Error class: unknown class><T>, block: RequestWithKnownMethodSpec.() -> Unit = {}): <Error class: unknown class>

Fetches the response to sending a PATCH request to the given URI, mapping the response body with the given BodyHandler. A spec block can be optionally passed to customize the request.

Link copied to clipboard
inline suspend fun <T> Client.post(uri: String, noinline block: RequestWithKnownMethodSpec.() -> Unit = {}): <Error class: unknown class>

Fetches the response to sending a POST request to the given URI, mapping the response body into T. A spec block can be optionally passed to customize the request.

suspend fun <T> Client.post(uri: String, bodyHandler: <Error class: unknown class><T>, block: RequestWithKnownMethodSpec.() -> Unit = {}): <Error class: unknown class>

Fetches the response to sending a POST request to the given URI, mapping the response body with the given BodyHandler. A spec block can be optionally passed to customize the request.

Link copied to clipboard
inline suspend fun <T> Client.put(uri: String, noinline block: RequestWithKnownMethodSpec.() -> Unit = {}): <Error class: unknown class>

Fetches the response to sending a PUT request to the given URI, mapping the response body into T. A spec block can be optionally passed to customize the request.

suspend fun <T> Client.put(uri: String, bodyHandler: <Error class: unknown class><T>, block: RequestWithKnownMethodSpec.() -> Unit = {}): <Error class: unknown class>

Fetches the response to sending a PUT request to the given URI, mapping the response body with the given BodyHandler. A spec block can be optionally passed to customize the request.

Link copied to clipboard

Creates a new Request as configured by the given spec block.

fun Request(request: <Error class: unknown class>, block: RequestSpec.() -> Unit): TaggableRequest

Creates a copy of the given request after configuring with the given spec block.

Link copied to clipboard
inline fun <T> AdapterCodec.subscriberOf(hints: BodyAdapter.Hints = Hints.empty()): <Error class: unknown class><T>

Returns a BodySubscriber for the given type and Hints.

Link copied to clipboard
inline fun <T : Any> <Error class: unknown class>.tag(): T?

Returns the tag associated with the given type if this request is a TaggableRequest and it has such a tag, or {@code null} otherwise.

Link copied to clipboard
inline suspend fun <T> ResponsePayload.to(): T

Converts this response payload into T.

Link copied to clipboard

Parses the given string into a CacheControl instance as specified by the Cache-Control header.

Parses the given strings into a CacheControl instance as specified by the Cache-Control header.

Link copied to clipboard
fun <Error class: unknown class>.toHttpString(valueToString: (String, String) -> String? = { name, value -> value }): <Error class: unknown class>

Returns a string representation for this Headers that is similar to how it would appear in an HTTP/1.1 response. valueToString can be used to control how header values appear, or whether they appear at all, in the returned string. You can use this to hide/exclude sensitive headers.

Link copied to clipboard

Parses the given string into a MediaType.

Link copied to clipboard
fun <Error class: unknown class>.toTaggableRequest(): TaggableRequest

Returns this request if it is a TaggableRequest, or a TaggableRequest copy with no tags otherwise.

Link copied to clipboard
inline fun <T> TypeRef(): TypeRef<T>

Captures T within a TypeRef.

Link copied to clipboard
suspend fun <T> ResponsePayload.with(bodyHandler: <Error class: unknown class><T>): T

Converts this payload to T using the given body handler.

Link copied to clipboard
fun <Error class: unknown class>.withMediaType(mediaType: MediaType): MimeBodyPublisher

Associated the given media type with this BodyPublisher through a MimeBodyPublisher. This allows the Client to automatically add a corresponding Content-Type header.