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

try_2.9.3.0.2.0.source-code.client.scala Maven / Gradle / Ivy

The newest version!
package bintry

import com.ning.http.client.AsyncHandler
import dispatch._, dispatch.Defaults._
import scala.concurrent.Future

object Client {
  type Handler[T] = AsyncHandler[T]
  trait Completion {
    def apply[T](handler: Client.Handler[T]): Future[T]
  }
}

abstract class Requests(
  credentials: Credentials, http: Http = Http)
  extends DefaultHosts
  with Methods {

  def request[T](req: Req)
                (handler: Client.Handler[T]): Future[T] =
    http(credentials.sign(req) > handler)

  def complete(req: Req): Client.Completion =
    new Client.Completion {
      override def apply[T](handler: Client.Handler[T]) =
        request(req)(handler)
    }
}

case class Client(user: String, token: String, http: Http = Http)
  extends Requests(BasicAuth(user, token))




© 2015 - 2025 Weber Informatics LLC | Privacy Policy