Created
October 19, 2017 11:18
-
-
Save adamw/437118c3390b61b849c11c4fdaa17a56 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.softwaremill.sttp._ | |
val sort: Option[String] = None | |
val query = "http language:scala" | |
// the `query` parameter is automatically url-encoded | |
// `sort` is removed, as the value is not defined | |
val request = sttp.get( | |
uri"https://api.github.com/search/repositories?q=$query&sort=$sort") | |
implicit val backend = HttpURLConnectionBackend() | |
val response = request.send() | |
// response.header(...): Option[String] | |
println(response.header("Content-Length")) | |
// response.unsafeBody: by default read into a String | |
println(response.unsafeBody) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment