aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/xyz/driver/pdsuicommon/utils/WriteableImplicits.scala
blob: 6c04dfa149c9e47dca0c49c96eab10d37a8422e5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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)
  )

}