-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rejigger things to be more testable to facilitate #8.
- Loading branch information
Showing
4 changed files
with
93 additions
and
74 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package io.keen.client.scala | ||
|
||
import dispatch._ | ||
import grizzled.slf4j.Logging | ||
import scala.concurrent.ExecutionContext.Implicits.global | ||
|
||
class HttpAdapter() extends Logging { | ||
|
||
/** | ||
* Perform the request with some debugging for good measure. | ||
* | ||
* @param req The request | ||
*/ | ||
def doRequest(req: Req, key: String): Future[Response] = { | ||
val breq = req.toRequest | ||
debug("%s: %s".format(breq.getMethod, breq.getUrl)) | ||
Http( | ||
req.setHeader("Content-type", "application/json; charset=utf-8") | ||
// Set the provided key, for authentication. | ||
.setHeader("Authorization", key) | ||
) map { res => | ||
Response(statusCode = res.getStatusCode, body =res.getResponseBody) | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package io.keen.client | ||
|
||
package object scala { | ||
|
||
case class Response(statusCode: Int, body: String) | ||
} |
Oops, something went wrong.