All Downloads are FREE. Search and download functionalities are using the official Maven repository.

eu.shiftforward.apso.spray.Implicits.scala Maven / Gradle / Ivy

There is a newer version: 0.13.11
Show newest version
package eu.shiftforward.apso.spray

import scalaz.{ Failure, Success, Validation }
import spray.httpx.marshalling.Marshaller

/**
 * Object containing implicit classes and methods related to spray.
 */
object Implicits {

  /**
   * Implicit method that provides a marshaller for `Validation` objects. It
   * relies on the existence of marshallers for each of the possible values in
   * this validation.
   */
  implicit def validationMarshaller[E, A](implicit me: Marshaller[E], ma: Marshaller[A]) =
    Marshaller[Validation[E, A]] { (value, ctx) =>
      value match {
        case Failure(e) => me(e, ctx)
        case Success(a) => ma(a, ctx)
      }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy