/docs/00.md

https://github.com/eed3si9n/gigahorse · Markdown · 88 lines · 65 code · 23 blank · 0 comment · 0 complexity · d1b831c0ed2159fbd5f08797ed61377e MD5 · raw file

  1. ---
  2. out: index.html
  3. ---
  4. [AHC]: https://github.com/AsyncHttpClient/async-http-client/tree/1.9.x
  5. [netty]: http://netty.io
  6. [okhttp]: http://square.github.io/okhttp/
  7. [sslconfig]: https://github.com/lightbend/ssl-config
  8. [config]: https://github.com/lightbend/config
  9. [ws]: https://www.playframework.com/documentation/2.5.x/ScalaWS
  10. [dispatch]: https://dispatchhttp.org/Dispatch.html
  11. [contraband]: http://www.scala-sbt.org/contraband/
  12. [akkahttp]: http://doc.akka.io/docs/akka-http/current/scala.html
  13. [@wsargent]: https://github.com/wsargent
  14. [@n8han]: https://github.com/n8han
  15. [@Duhemm]: https://github.com/Duhemm
  16. [@alexdupre]: https://github.com/alexdupre
  17. Gigahorse
  18. =========
  19. Gigahorse is an HTTP client for Scala that can wrap either
  20. [Square OkHttp][okhttp], [Async Http Client][AHC], or [Akka HTTP][akkahttp] underneath.
  21. ### Setup
  22. For Square OkHttp Client:
  23. ```scala
  24. libraryDependencies += "com.eed3si9n" %% "gigahorse-okhttp" % "$gigahorse_version$"
  25. ```
  26. For Async HTTP Client:
  27. ```scala
  28. libraryDependencies += "com.eed3si9n" %% "gigahorse-asynchttpclient" % "$gigahorse_version$"
  29. ```
  30. Akka HTTP support is experimental:
  31. ```scala
  32. libraryDependencies += "com.eed3si9n" %% "gigahorse-akka-http" % "$gigahorse_version$"
  33. ```
  34. ### Dependencies
  35. Gigahorse-OkHttp depends on Scala and [Square OkHttp][okhttp].
  36. It also depends on [Lightbend SSL Config][sslconfig] and [Lightbend Config][config].
  37. Gigahorse-AsyncHttpClient depends on Scala, [AHC 2.0][AHC], which brings in [Netty 4][netty].
  38. Gigahorse-Akka-HTTP is experimental, and not all features are hooked up.
  39. ### Credits
  40. - The implementation was originally based from [The Play WS API][ws],
  41. including the way AHC is called and the choice of default values.
  42. In particular, it uses [Lightbend Config][config] and [@wsargent][@wsargent]'s [SSL Config][sslconfig],
  43. which uses securer defaults.
  44. - API design is also strongly influenced by that of [Dispatch Reboot][dispatch] by [@n8han][@n8han].
  45. - All datatypes are generated using [Contraband][contraband], which [@Duhemm][@Duhemm] and I worked on.
  46. - [@alexdupre][@alexdupre] contributed AHC 2.0 migration and WebSocket support.
  47. - Finally, props to underlying HTTP libraries for the actual HTTP work.
  48. ### License
  49. Apache v2
  50. ### Quick start
  51. Here's a quick example of how to make a GET call using Gigahorse:
  52. ```console
  53. scala> import gigahorse._, support.okhttp.Gigahorse
  54. scala> import scala.concurrent._, duration._
  55. scala> val http = Gigahorse.http(Gigahorse.config)
  56. scala> val r = Gigahorse.url("https://api.duckduckgo.com").get.
  57. addQueryString(
  58. "q" -> "1 + 1"
  59. )
  60. scala> val f = http.run(r, Gigahorse.asString andThen {_.take(60)})
  61. scala> Await.result(f, 120.seconds)
  62. scala> http.close()
  63. ```
  64. <div style="margin: 100px"></div>
  65. ![Gigahorse](files/gigahorse.jpg)