hack API accepts

This commit is contained in:
Thibault Duplessis 2014-09-30 21:30:14 +02:00
parent 276bc1d21e
commit 48a1b4afef

View file

@ -173,15 +173,10 @@ private[controllers] trait LilaController
protected def authorizationFailed(req: RequestHeader): Result =
Forbidden("no permission")
private val MediaSubTypeRegex = """^vnd\.lichess\.v(\d+)\+json""".r
protected def negotiate(html: => Fu[Result], api: Int => Fu[Result])(implicit ctx: Context): Fu[Result] = {
render.async {
case mediaRange => mediaRange.mediaSubType match {
case MediaSubTypeRegex(v) => parseIntOption(v).fold(html) { version =>
api(version) map (_ as JSON)
}
case _ => html
}
case mediaRange if mediaRange.mediaSubType == "json" => api(1) map (_ as JSON)
case _ => html
}(ctx.req)
}