document /tv/channels and add jsonp support
parent
784e8257a2
commit
18fe3d425f
10
README.md
10
README.md
|
@ -636,6 +636,16 @@ curl 'https://lichess.org/api/tournament/x5WNIngd?page=1'
|
|||
|
||||
JSONP is available.
|
||||
|
||||
### `GET /tv/channels` fetch current tournaments
|
||||
|
||||
Returns the current game ID and best player for each TV channel: https://lichess.org/tv
|
||||
|
||||
```
|
||||
> curl https://lichess.org/tv/channels
|
||||
```
|
||||
|
||||
JSONP is available.
|
||||
|
||||
Credits
|
||||
-------
|
||||
|
||||
|
|
|
@ -295,7 +295,7 @@ object Api extends LilaController {
|
|||
def toApiResult(json: Option[JsValue]): ApiResult = json.fold[ApiResult](NoData)(Data.apply)
|
||||
def toApiResult(json: Seq[JsValue]): ApiResult = Data(JsArray(json))
|
||||
|
||||
private def ApiRequest(js: Context => Fu[ApiResult]) = Open { implicit ctx =>
|
||||
def ApiRequest(js: Context => Fu[ApiResult]) = Open { implicit ctx =>
|
||||
js(ctx) map toHttp
|
||||
}
|
||||
|
||||
|
|
|
@ -28,12 +28,12 @@ object Tv extends LilaController {
|
|||
}
|
||||
}
|
||||
|
||||
def channels = Action.async {
|
||||
def channels = Api.ApiRequest { implicit ctx =>
|
||||
import play.api.libs.json._
|
||||
implicit val championWrites = Json.writes[lila.tv.Tv.Champion]
|
||||
Env.tv.tv.getChampions map {
|
||||
_.channels map { case (chan, champ) => chan.name -> champ }
|
||||
} map { Json.toJson(_) } map { Ok(_) }
|
||||
} map { Json.toJson(_) } map Api.Data.apply
|
||||
}
|
||||
|
||||
private def lichessTv(channel: lila.tv.Tv.Channel)(implicit ctx: Context) =
|
||||
|
|
Loading…
Reference in New Issue