Permalink
Browse files

removing redundant temp variables when generating json

  • Loading branch information...
1 parent e696056 commit 758527e16b036bf62996f7a1219c3fe158331808 @kelvl kelvl committed Apr 29, 2013
Showing with 20 additions and 24 deletions.
  1. +20 −24 src/main/scala/com/twilio/shadow/UIService.scala
@@ -32,14 +32,15 @@ object JsonUtil {
def shadowEntryJson(entry: ShadowEntry) = {
val req = httpRequestToJson(entry.request)
- val json =
- ("request" -> (
- ("original" -> req) ~
- ("modified" -> req)
- )) ~
- ("results" -> List(entry.responses._1, entry.responses._2).map( x => httpResponseToJson(x._1) ~ ("elapsed_time" -> x._2) ))
-
- json
+ ("request" -> (
+ ("original" -> req) ~
+ ("modified" -> req)
+ )) ~
+ ("results" -> List(entry.responses._1, entry.responses._2)
+ .map( x => httpResponseToJson(x._1) ~ ("elapsed_time" -> x._2) )
+ )
+
+
}
def httpRequestToJson(httpRequest: HttpRequest) = {
@@ -50,25 +51,20 @@ object JsonUtil {
val queryParams = request.queryParams
- val json =
- ("url" -> request.path) ~
- ("headers" -> request.headers.map { x => x.name -> x.value }.toMap ) ~
- ("post" -> formParams) ~
- ("method" -> request.method.value) ~
- ("get" -> queryParams)
- json
+ ("url" -> request.path) ~
+ ("headers" -> request.headers.map { x => x.name -> x.value }.toMap ) ~
+ ("post" -> formParams) ~
+ ("method" -> request.method.value) ~
+ ("get" -> queryParams)
}
def httpResponseToJson(httpResponse: HttpResponse) = {
-
- val json =
- ("headers" -> httpResponse.headers.map { x => (
- (x.name -> x.value)
- ) }.toMap) ~
- ("status_code" -> httpResponse.status.value) ~
- ("type" -> "http_response") ~
- ("body" -> httpResponse.entity.asString)
- json
+ ("headers" -> httpResponse.headers.map { x => (
+ (x.name -> x.value)
+ ) }.toMap) ~
+ ("status_code" -> httpResponse.status.value) ~
+ ("type" -> "http_response") ~
+ ("body" -> httpResponse.entity.asString)
}
}

0 comments on commit 758527e

Please sign in to comment.