-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added bodyAsBytes to ApiHttpResponse, fixed #1
- Loading branch information
1 parent
eedfa7f
commit e1a34a7
Showing
7 changed files
with
118 additions
and
43 deletions.
There are no files selected for viewing
23 changes: 19 additions & 4 deletions
23
core/src/main/scala/scommons/api/http/ApiHttpResponse.scala
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 |
---|---|---|
@@ -1,6 +1,21 @@ | ||
package scommons.api.http | ||
|
||
case class ApiHttpResponse(url: String, | ||
status: Int, | ||
headers: Map[String, Seq[String]], | ||
body: String) | ||
class ApiHttpResponse(val url: String, | ||
val status: Int, | ||
val headers: Map[String, Seq[String]], | ||
getBody: => String, | ||
getBodyAsBytes: => Seq[Byte]) { | ||
|
||
private lazy val _body: String = getBody | ||
private lazy val _bodyAsBytes: Seq[Byte] = getBodyAsBytes | ||
|
||
def body: String = _body | ||
def bodyAsBytes: Seq[Byte] = _bodyAsBytes | ||
} | ||
|
||
object ApiHttpResponse { | ||
|
||
def apply(url: String, status: Int, headers: Map[String, Seq[String]], body: String): ApiHttpResponse = { | ||
new ApiHttpResponse(url, status, headers, body, body.getBytes) | ||
} | ||
} |
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
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
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