Package-level declarations

Types

Link copied to clipboard
class BadGateway(val url: String, val method: HttpMethod, message: String, val response: Response? = null) : RemoteRequestException
Link copied to clipboard
class BadRequest(val url: String, val method: HttpMethod, message: String, val response: Response? = null) : RemoteRequestException
Link copied to clipboard
class Forbidden(val url: String, val method: HttpMethod, message: String, val response: Response? = null) : RemoteRequestException
Link copied to clipboard

HTTP methods.

Link copied to clipboard
class NotAllowed(val url: String, val method: HttpMethod, message: String, val response: Response? = null) : RemoteRequestException
Link copied to clipboard
class NotFound(val url: String, val method: HttpMethod, message: String, val response: Response? = null) : RemoteRequestException
Link copied to clipboard
class NotImplemented(val url: String, val method: HttpMethod, message: String, val response: Response? = null) : RemoteRequestException
Link copied to clipboard
open class RemoteRequestException(val code: Short, val url: String, val method: HttpMethod, message: String, val response: Response? = null) : Exception
Link copied to clipboard

HTTP response body types.

Link copied to clipboard
open class RestClient(block: RestClientConfig.() -> Unit = {})

A HTTP REST client

Link copied to clipboard

REST Client configuration

Link copied to clipboard

REST request configuration

Link copied to clipboard
data class RestResponse<T>(val data: T?, val textStatus: String, val response: Response)

A response wrapper

Link copied to clipboard
class ServerError(val url: String, val method: HttpMethod, message: String, val response: Response? = null) : RemoteRequestException
Link copied to clipboard
class ServiceUnavailable(val url: String, val method: HttpMethod, message: String, val response: Response? = null) : RemoteRequestException
Link copied to clipboard
class Unauthorized(val url: String, val method: HttpMethod, message: String, val response: Response? = null) : RemoteRequestException
Link copied to clipboard
class XHRError(val url: String, val method: HttpMethod, message: String, val response: Response? = null) : RemoteRequestException

Code 0 does not represent any http status, it represent XHR error (e.g. network error, CORS failure).

Properties

Link copied to clipboard
const val HTTP_BAD_GATEWAY: Short = 502
Link copied to clipboard
const val HTTP_BAD_REQUEST: Short = 400
Link copied to clipboard
const val HTTP_FORBIDDEN: Short = 403
Link copied to clipboard
const val HTTP_NO_CONTENT: Short = 204
Link copied to clipboard
const val HTTP_NOT_ALLOWED: Short = 405
Link copied to clipboard
const val HTTP_NOT_FOUND: Short = 404
Link copied to clipboard
const val HTTP_NOT_IMPLEMENTED: Short = 501
Link copied to clipboard
const val HTTP_SERVER_ERROR: Short = 500
Link copied to clipboard
Link copied to clipboard
const val HTTP_UNAUTHORIZED: Short = 401
Link copied to clipboard
const val XHR_ERROR: Short = 0

Functions

Link copied to clipboard
inline suspend fun <T : Any> RestClient.call(url: String, crossinline block: RestRequestConfig<T, JsAny>.() -> Unit = {}): T
inline suspend fun <T : Any, V : Any> RestClient.call(url: String, data: V, crossinline block: RestRequestConfig<T, V>.() -> Unit = {}): T

Makes a http request to the server, returning data directly.

Link copied to clipboard
suspend fun RestClient.callDynamic(url: String, block: RestRequestConfig<JsAny, JsAny>.() -> Unit = {}): JsAny?
inline suspend fun <V : Any> RestClient.callDynamic(url: String, data: V, crossinline block: RestRequestConfig<JsAny, V>.() -> Unit = {}): JsAny?

Makes a http request to the server, returning data directly.

Link copied to clipboard
inline suspend fun <T : Any, V : Any> RestClient.post(url: String, data: V, crossinline block: RestRequestConfig<T, V>.() -> Unit = {}): T

Makes a http POST request to the server, returning data directly.

Link copied to clipboard
inline suspend fun <V : Any> RestClient.postDynamic(url: String, data: V, crossinline block: RestRequestConfig<JsAny, V>.() -> Unit = {}): JsAny?

Makes a http POST request to the server, returning data directly.

Link copied to clipboard
inline suspend fun <T : Any> RestClient.request(url: String, crossinline block: RestRequestConfig<T, JsAny>.() -> Unit = {}): RestResponse<T>
inline suspend fun <T : Any, V : Any> RestClient.request(url: String, data: V, crossinline block: RestRequestConfig<T, V>.() -> Unit = {}): RestResponse<T>

Makes a http request to the server, returning the response object.

Link copied to clipboard
inline suspend fun <V : Any> RestClient.requestDynamic(url: String, data: V, crossinline block: RestRequestConfig<JsAny, V>.() -> Unit = {}): RestResponse<JsAny>

Makes a http request to the server, returning the response object.