Git Product home page Git Product logo

http-client's Introduction

SIMPLY SCALA HTTP CLIENT

This project provides a fast, asynchronous & and non-blocking http client API.
It encapsulate, in Scala 2.10 API, the project async-http-client

This works in a Java 6+ environment

The project is available in 0.2-SNAPSHOT version !

The actual project release version is 0.1

Roadmap

  • simple GET request OK (0.1)
  • simple POST request OK (0.1)
  • async api OK (0.1)
  • HEAD, PUT, DELETE request OK (0.1)
  • fluent API TODO
  • sync api TODO
  • proxy handling TODO
  • Akka actor plugin api TODO
  • other HTTP verb TODO
  • WebSocket TODO
  • SSL TODO
  • Response streaming TODO

Installation

Git repo

simplyscala-server is a SBT project.
It use 0.12 sbt version.

Maven dependency


   <dependency>
      <groupId>com.github.simplyscala</groupId>
      <artifactId>http-client_2.10</artifactId>
      <version>0.1</version>
   </dependency>

SBT dependency


    libraryDependencies += "com.github.simplyscala" %% "http-client" % "0.1"
Only the following Scala versions 2.10.x are currently supported.

Play! specific dependency management

In your play! project Build file :


    object ApplicationBuild extends Build {

        val appDependencies = Seq (
            "com.github.simplyscala" %% "http-client" % "0.1"
        )
    }

Simple JAR file

0.1 jar version

Try SNAPSHOT version

You could be tempted to try SNAPSHOT version to test project’s next features.

with Maven


<project ...>

   <repositories>
      <repository>
         <id>maven snapshot</id>
         <url>https://oss.sonatype.org/content/repositories/snapshots</url>
      </repository>
   </repositories>

   ...

   <dependency>
      <groupId>com.github.simplyscala</groupId>
      <artifactId>http-client_2.10</artifactId>
      <version>0.2-SNAPSHOT</version>
    </dependency>

with SBT


   resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"

   libraryDependencies += "com.github.simplyscala" %% "http-client" % "0.2-SNAPSHOT"

Usage

Simple GET HTTP request

val response: Future[Response] = new AsyncHttpClient().get("http://someUrl/path?param1=value1;param2=value2")

Simple POST HTTP request

val response: Future[Response] = new AsyncHttpClient().post("http://someUrl/path", Map("param" -> "value")

How to use scala.concurent.Future[+T] api

The AsyncHttpClient return asynchronous response. With Scala language, we use Future api.
When we perform, for example, GET request :
val response: Future[Response] = new AsyncHttpClient().get("http://github.com/simplyscala/http-client")

We are two major ways to use this result :

Callback api

// link to Future SIP & ScalaDoc

Monadic api

Blocking

If we use asynchronous api to perform HTTP request, it is not recommended to block the result. But sometimes, we must :D


import scala.concurrent.duration._
...

val futureResponse: Future[Response] = new AsyncHttpClient().get("http://github.com/simplyscala/http-client")
val response = Await.result(futureResponse, 1 second)

http-client's People

Contributors

ubourdon avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

alfonso777

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.