Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

handle handlerverbs from json verbs, fixes #40

  • Loading branch information...
commit 3d0c476bfd50121cd8640bf41c01dccfcb3c4e27 1 parent d9d75d3
@n8han n8han authored
View
1  core/src/main/scala/callbacks.scala
@@ -70,7 +70,6 @@ trait ImplicitCallbackVerbs {
implicit def toCallbackVerbs(req: Request) = new CallbackVerbs(req)
implicit def stringToCallbackVerbs(str: String) = new CallbackVerbs(new Request(str))
}
-object CallbackVerbs extends ImplicitCallbackVerbs
class CallbackVerbs(subject: Request) {
import Callback._
View
1  core/src/main/scala/handlers.scala
@@ -52,7 +52,6 @@ trait ImplicitHandlerVerbs {
implicit def toHandlerVerbs(req: Request) = new HandlerVerbs(req)
implicit def stringToHandlerVerbs(str: String) = new HandlerVerbs(new Request(str))
}
-object HandlerVerbs extends ImplicitHandlerVerbs
class HandlerVerbs(request: Request) {
/** Handle InputStream in block, handle gzip if so encoded. Passes on any charset
View
3  http+json/src/main/scala/JsHttp.scala
@@ -3,6 +3,7 @@ import dispatch._
trait ImplicitJsHandlers {
/** Add JSON-processing method ># to dispatch.Request */
+ implicit def handlerToJsHandlers(r: HandlerVerbs) = new JsHandlers(r)
implicit def requestToJsHandlers(r: Request) = new JsHandlers(r)
implicit def stringToJsHandlers(r: String) = new JsHandlers(new Request(r))
}
@@ -11,7 +12,7 @@ trait JsHttp extends ImplicitJsHandlers with Js
object JsHttp extends JsHttp
-class JsHandlers(subject: Request) {
+class JsHandlers(subject: HandlerVerbs) {
/** Process response as JsValue in block */
def ># [T](block: json.Js.JsF[T]) = subject >> { (stm, charset) =>
block(json.Js(stm, charset))
View
21 lift-json/src/main/scala/LiftJson.scala
@@ -7,21 +7,28 @@ import JsonDSL._
import java.util.Date
trait ImplicitJsonVerbs {
- /** Add JSON-processing method ># to dispatch.Request */
- implicit def requestToJsonVerbs(r: dispatch.Request) = new JsonVerbs(r)
- /** Add String conversion since Http#str2req implicit will not chain. */
- implicit def stringToJsonVerbs(r: String) = new JsonVerbs(new Request(r))
+ /** Add JSON-processing method ># to dispatch.HandlerVerbs */
+ implicit def handlerToJsonVerbs(r: HandlerVerbs) =
+ new JsonHandlerVerbs(r)
+ implicit def requestToJsonVerbs(r: Request) =
+ new JsonHandlerVerbs(r)
+ implicit def stringToJsonVerbs(str: String) =
+ new JsonHandlerVerbs(new Request(str))
+ implicit def callbackToJsonVerbs(r: CallbackVerbs) =
+ new JsonCallbackVerbs(r)
}
-class JsonVerbs(subject: Request) {
+class JsonHandlerVerbs(subject: HandlerVerbs) {
/** Process response as JsValue in block */
def ># [T](block: JValue => T) = subject >> { (stm, charset) =>
block(JsonParser.parse(new java.io.InputStreamReader(stm, charset)))
}
def as_pretty = this ># { js => Js.prettyrender(js) }
/** Process streaming json messages, separated by newlines, in callbacks */
- def ^# [T](block: JValue => T) = subject ^-- { s => block(JsonParser.parse(s)) }
}
-
+class JsonCallbackVerbs(subject: CallbackVerbs) {
+ def ^# [T](block: JValue => T) =
+ subject ^-- { s => block(JsonParser.parse(s)) }
+}
object Js extends TypeMappers with ImplicitJsonVerbs {
implicit def jvlistcomb[LT](block: JValue => List[LT]) = new JvListComb(block)
class JvListComb[LT](block: JValue => List[LT]) {

0 comments on commit 3d0c476

Please sign in to comment.
Something went wrong with that request. Please try again.