TypedRestClient
open class TypedRestClient<E : ErrorSpec>(client: HttpClient = HttpClientFactory.create(), baseUrl: String = "", mapper: RestErrorMapper<E, *>)(source)
A REST client whose every call works in Raise of the caller's error type E.
A request that cannot be sent raises RestErrorMapper.networkError, a non-2xx status raises RestErrorMapper.errorOf, and a success body that does not decode raises RestErrorMapper.parseError. Success and error bodies both decode through client's content negotiation, so the codec lives in the HttpClient (see HttpClientFactory.create).
request is the general entry point: any method, any body Ktor can send. The verbs are sugar over it: get, post, put, patch, delete, head and options speak JSON; postMultipart and postForm send the two form encodings. Each takes a builder for headers, query parameters and anything else on the request.
Inheritors
Constructors
Link copied to clipboard
constructor(client: HttpClient = HttpClientFactory.create(), baseUrl: String = "", mapper: RestErrorMapper<E, *>)