How to construct reverse routes in (Scala) Play 2.4 outside controllers? If I import controllers._
and try to use routes, I get a compilation error:
Cannot find any HTTP Request Header here
package models
import org.joda.time._
import play.api.libs.json._
case class Attendee (id: Long, status: Boolean, ... , pictureUrl: Option[String], ...)
object Attendee { implicit val attendeeWrites = new Writes[Attendee] {
def writes(att: Attendee) = Json.obj( "id" -> att.id, "picture" -> att.pictureUrl.map
{ somePictureUrl => routes.PrivateWS.getAttendeeImage(att.eventId, att.id)
.absoluteURL() })
import play.api.mvc.Request
, and: \ndef writes(att: Attendee)(implicit request: Request[_]) = Json.obj( "id"...
– airudah