aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/xyz/driver/pdsuicommon/utils/WriteableImplicits.scala
blob: 2c66a23221c1182c168980b18656463016d7b65e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
package xyz.driver.pdsuicommon.utils

import play.api.http.{ContentTypes, Writeable}
import play.api.libs.json.{Json, Writes}

// @TODO this should be an object with a method, that gets HTTP-headers and returns suitable Writeable
trait WriteableImplicits {

  // Write JSON by default at now
  implicit def defaultWriteable[T](implicit inner: Writes[T]) = Writeable[T](
    { x: T => Writeable.writeableOf_JsValue.transform(Json.toJson(x)) },
    Option(ContentTypes.JSON)
  )

}