All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.malliina.push.AsyncHttp.scala Maven / Gradle / Ivy

There is a newer version: 1.24.4
Show newest version
package com.malliina.push

import com.malliina.http.OkClient

import scala.concurrent.Future

object AsyncHttp extends AsyncHttp

trait AsyncHttp {
  def withClient[U](code: OkClient => Future[U]): Future[U] =
    usingAsync(OkClient.default)(code)

  def usingAsync[T <: AutoCloseable, U](res: T)(code: T => Future[U]): Future[U] = {
    val result = code(res)
    result.onComplete(_ => res.close())
    result
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy