HttpClient

com.malliina.http.HttpClient
See theHttpClient companion object
trait HttpClient[F[_]] extends Closeable

Attributes

Companion:
object
Graph
Supertypes
trait Closeable
trait AutoCloseable
class Object
trait Matchable
class Any
Known subtypes
class OkClient

Members list

Concise view

Type members

Classlikes

implicit class FOps[T](f: F[T])

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Value members

Abstract methods

def close(): Unit
def execute(request: Request): F[OkHttpResponse]
def fail[T](e: Exception): F[T]
def flatMap[T, U](t: F[T])(f: T => F[U]): F[U]
def raw(request: Request): F[Response]
def streamed[T](request: Request)(consume: Response => F[T]): F[T]
def success[T](t: T): F[T]

Concrete methods

def download(url: FullUrl, to: Path, headers: Map[String, String]): F[Either[StatusError, StorageSize]]

Downloads url to to, returning the number of bytes written to to.

Downloads url to to, returning the number of bytes written to to.

Attributes

headers

http headers

to

destination, a file

url

url to download

Returns:

bytes written

def get(url: FullUrl, headers: Map[String, String]): F[OkHttpResponse]
def getAs[T : Decoder](url: FullUrl, headers: Map[String, String]): F[T]
def multiPart(url: FullUrl, headers: Map[String, String], parts: Map[String, String], files: Seq[MultiPartFile]): F[OkHttpResponse]
def parse[T : Decoder](response: OkHttpResponse, url: FullUrl): F[T]

Parses the response as a T.

Parses the response as a T.

The returned Future fails with a ResponseError if parsing fails.

Attributes

T

type to parse

response

HTTP response

url

the request URL

Returns:

a parsed response

def post(url: FullUrl, body: RequestBody, headers: Map[String, String]): F[OkHttpResponse]
def postAs[W : Encoder, T : Decoder](url: FullUrl, json: W, headers: Map[String, String]): F[T]
def postFile(url: FullUrl, mediaType: MediaType, file: Path, headers: Map[String, String]): F[OkHttpResponse]
def postForm(url: FullUrl, form: Map[String, String], headers: Map[String, String]): F[OkHttpResponse]
def postFormAs[T : Decoder](url: FullUrl, form: Map[String, String], headers: Map[String, String]): F[T]
def postJson(url: FullUrl, json: Json, headers: Map[String, String]): F[OkHttpResponse]
def postJsonAs[T : Decoder](url: FullUrl, json: Json, headers: Map[String, String]): F[T]

Implicits

Implicits

final implicit def FOps[T](f: F[T]): FOps[T]