A simple and ready to use akka http client for building HTTP requests and processing responses with custom response handlers
akka-http-rest-client is based on the Akka HTTP architecture. The goal is to have an easy to use REST client, which can be used in almost any Scala project
- Easy using like Spring Rest Templates
- Builder style for a simple request building
- Almost all http methods available
- Default response processor support
- Functionality to un marshall responses with a given un marshaller (less code for you)
- Development was focused on JSON support
- Compression support for deflate / gzip responses
https://freshwood.github.io/akka-http-rest-client/
// All releases are published to bintray
resolvers += Resolver.bintrayRepo("freshwood", "maven")
libraryDependencies ++= List(
"net.softler" %% "akka-http-rest-client" % "0.2.1"
)
(ammonite)
interp.repositories() ++= Seq(coursier.MavenRepository("https://dl.bintray.com/freshwood/maven/"))
import $ivy.`net.softler::akka-http-rest-client:0.2.1`
Simple as hell
// When you have an unmarshaller available: (e.g: RootJsonFormat[User])
val result: Future[User] = ClientRequest("http://test.de/1").withJson.get[User]
// Or you just maka a call...
val result: Future[ClientResponse] = testRequest.get()
// Now you can process the response with the inline processor
// The future will fail when an error occurs
val processed: Future[ResponseEntity] = result map(_.process)
// Or you just handle the response by your own
val original: Future[HttpResponse] = result.map(_.response)
// Just a request on a API with GZIP responses
val result: Future[ClientResponse] = encodedRequest.withText.get()
// Just map over the entire response an encoder to get your desired object
val string = result.map(_.decode).flatMap(_.as[String])
It would be a pleasure to see a nice contribution. Just add a PR (Pull Request) Or you add an issue with an corresponding PR.
This code is open source software licensed under the MIT License