2012-05-26 06:31:05 -06:00
|
|
|
package controllers
|
|
|
|
|
2013-03-14 12:16:36 -06:00
|
|
|
import lila.api._
|
2012-05-26 06:31:05 -06:00
|
|
|
|
|
|
|
import play.api.http._
|
2012-11-30 07:36:36 -07:00
|
|
|
import play.api.mvc.Codec
|
2012-05-26 06:31:05 -06:00
|
|
|
|
|
|
|
trait ResponseWriter {
|
|
|
|
|
2012-11-30 07:36:36 -07:00
|
|
|
implicit def wUnit(implicit codec: Codec): Writeable[Unit] =
|
2014-02-17 02:12:19 -07:00
|
|
|
Writeable[Unit]((_: Unit) => codec encode "ok")
|
2012-05-26 06:31:05 -06:00
|
|
|
implicit def ctoUnit: ContentTypeOf[Unit] =
|
|
|
|
ContentTypeOf[Unit](Some(ContentTypes.TEXT))
|
|
|
|
|
2012-11-30 07:36:36 -07:00
|
|
|
implicit def wFloat(implicit codec: Codec): Writeable[Float] =
|
2014-02-17 02:12:19 -07:00
|
|
|
Writeable[Float]((f: Float) => codec encode f.toString)
|
2012-05-26 06:31:05 -06:00
|
|
|
implicit def ctoFloat: ContentTypeOf[Float] =
|
|
|
|
ContentTypeOf[Float](Some(ContentTypes.TEXT))
|
|
|
|
|
2012-11-30 07:36:36 -07:00
|
|
|
implicit def wLong(implicit codec: Codec): Writeable[Long] =
|
2014-02-17 02:12:19 -07:00
|
|
|
Writeable[Long]((a: Long) => codec encode a.toString)
|
2012-05-26 06:31:05 -06:00
|
|
|
implicit def ctoLong: ContentTypeOf[Long] =
|
|
|
|
ContentTypeOf[Long](Some(ContentTypes.TEXT))
|
|
|
|
|
2012-11-30 07:36:36 -07:00
|
|
|
implicit def wInt(implicit codec: Codec): Writeable[Int] =
|
2014-02-17 02:12:19 -07:00
|
|
|
Writeable[Int]((i: Int) => codec encode i.toString)
|
2012-05-26 06:31:05 -06:00
|
|
|
implicit def ctoInt: ContentTypeOf[Int] =
|
|
|
|
ContentTypeOf[Int](Some(ContentTypes.TEXT))
|
|
|
|
|
2012-11-30 07:36:36 -07:00
|
|
|
implicit def wOptionString(implicit codec: Codec): Writeable[Option[String]] =
|
2014-02-17 02:12:19 -07:00
|
|
|
Writeable[Option[String]]((i: Option[String]) => codec encode ~i)
|
2012-05-26 06:31:05 -06:00
|
|
|
implicit def ctoOptionString: ContentTypeOf[Option[String]] =
|
|
|
|
ContentTypeOf[Option[String]](Some(ContentTypes.TEXT))
|
|
|
|
}
|