Simple and concise HTTP client library for Scala

后端 未结 11 1854
梦如初夏
梦如初夏 2020-12-12 20:26

I need a mature HTTP client library that is idiomatic to scala, concise in usage, simple semantics. I looked at the Apache HTTP and the Scala Dispatch and numerous new libra

11条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-12 20:44

    I did a comparison of most major HTTP client libraries available

    Dispatch, and a few others libraries, are not maintained anymore. The only serious ones currently are spray-client and Play! WS.

    spray-client is a bit arcane in its syntax. play-ws is quite easy to use :

    (build.sbt)

    libraryDependencies += "com.typesafe.play" %% "play-ws" % "2.4.3"
    

    (basic usage)

    val wsClient = NingWSClient()
    wsClient
      .url("http://wwww.something.com")
      .get()
      .map { wsResponse =>
        // read the response
    }
    

提交回复
热议问题