package com.github.vonnagy.service.container.http

import net.liftweb.json.Formats
import net.liftweb.json.ext.JodaTimeSerializers
import spray.http._
import spray.httpx.LiftJsonSupport
import spray.httpx.marshalling.{BasicMarshallers, Marshaller, MetaMarshallers}

trait DefaultMarshallers extends MetaMarshallers with BasicMarshallers {

  def liftJson(implicit fmt: Formats): LiftJsonSupport = new LiftJsonSupport {
    implicit def liftJsonFormats = fmt
  }

  // The implicit formats used for serialization. This can be overridden
  implicit def jsonFormats = net.liftweb.json.DefaultFormats ++ JodaTimeSerializers.all

  def jsonUnmarshaller[T: Manifest] = liftJson.liftJsonUnmarshaller[T]

  def jsonMarshaller[T <: AnyRef] = liftJson.liftJsonMarshaller

  def plainMarshaller[T <: Any] =
    Marshaller.delegate[T, String](ContentTypes.`text/plain`)(_.toString)
}

package com.github.vonnagy.service.container.http

import net.liftweb.json.ext.JodaTimeSerializers
import spray.http._
import spray.httpx.LiftJsonSupport
import spray.httpx.marshalling.{BasicMarshallers, Marshaller, MetaMarshallers}

trait DefaultMarshallers extends MetaMarshallers with BasicMarshallers {

  val lift = new LiftJsonSupport {
    implicit def liftJsonFormats = net.liftweb.json.DefaultFormats ++ JodaTimeSerializers.all
  }

  implicit def jsonFormats = lift.liftJsonFormats

  def jsonUnmarshaller[T: Manifest] = lift.liftJsonUnmarshaller[T]

  def jsonMarshaller[T <: AnyRef] = lift.liftJsonMarshaller

  def plainMarshaller[T <: Any] =
    Marshaller.delegate[T, String](ContentTypes.`text/plain`)(_.toString)
}

--- 
+++ 
@@ -1,5 +1,6 @@
 package com.github.vonnagy.service.container.http
 
+import net.liftweb.json.Formats
 import net.liftweb.json.ext.JodaTimeSerializers
 import spray.http._
 import spray.httpx.LiftJsonSupport
@@ -7,15 +8,16 @@
 
 trait DefaultMarshallers extends MetaMarshallers with BasicMarshallers {
 
-  val lift = new LiftJsonSupport {
-    implicit def liftJsonFormats = net.liftweb.json.DefaultFormats ++ JodaTimeSerializers.all
+  def liftJson(implicit fmt: Formats): LiftJsonSupport = new LiftJsonSupport {
+    implicit def liftJsonFormats = fmt
   }
 
-  implicit def jsonFormats = lift.liftJsonFormats
+  // The implicit formats used for serialization. This can be overridden
+  implicit def jsonFormats = net.liftweb.json.DefaultFormats ++ JodaTimeSerializers.all
 
-  def jsonUnmarshaller[T: Manifest] = lift.liftJsonUnmarshaller[T]
+  def jsonUnmarshaller[T: Manifest] = liftJson.liftJsonUnmarshaller[T]
 
-  def jsonMarshaller[T <: AnyRef] = lift.liftJsonMarshaller
+  def jsonMarshaller[T <: AnyRef] = liftJson.liftJsonMarshaller
 
   def plainMarshaller[T <: Any] =
     Marshaller.delegate[T, String](ContentTypes.`text/plain`)(_.toString)
Allow for override JSON formats
