controller code cleanup
This commit is contained in:
parent
de3849bffd
commit
ec653582ab
|
@ -219,7 +219,7 @@ private[controllers] trait LilaController
|
|||
|
||||
def notFound(implicit ctx: Context): Fu[Result] = negotiate(
|
||||
html =
|
||||
if (HTTPRequest isSynchronousHttp ctx.req) Main notFound ctx.req
|
||||
if (HTTPRequest isSynchronousHttp ctx.req) Main notFound ctx
|
||||
else fuccess(Results.NotFound("Resource not found")),
|
||||
api = _ => notFoundJson("Resource not found")
|
||||
)
|
||||
|
@ -255,7 +255,10 @@ private[controllers] trait LilaController
|
|||
|
||||
protected def authorizationFailed(implicit ctx: Context): Fu[Result] = negotiate(
|
||||
html =
|
||||
if (HTTPRequest isSynchronousHttp ctx.req) Main authFailed ctx.req
|
||||
if (HTTPRequest isSynchronousHttp ctx.req) fuccess {
|
||||
lila.mon.http.response.code403()
|
||||
Forbidden(views.html.base.authFailed())
|
||||
}
|
||||
else fuccess(Results.Forbidden("Authorization failed")),
|
||||
api = _ => fuccess(Forbidden(jsonError("Authorization failed")))
|
||||
)
|
||||
|
|
|
@ -6,6 +6,7 @@ import play.api.libs.json._
|
|||
import play.api.mvc._
|
||||
|
||||
import lila.app._
|
||||
import lila.api.Context
|
||||
import lila.common.HTTPRequest
|
||||
import lila.hub.actorApi.captcha.ValidCaptcha
|
||||
import makeTimeout.large
|
||||
|
@ -111,11 +112,11 @@ object Main extends LilaController {
|
|||
"observation" -> Glyph.Observation.display
|
||||
)) as JSON
|
||||
}
|
||||
def glyphs = Action { req =>
|
||||
def glyphs = Action {
|
||||
glyphsResult
|
||||
}
|
||||
|
||||
def image(id: String, hash: String, name: String) = Action.async { req =>
|
||||
def image(id: String, hash: String, name: String) = Action.async {
|
||||
Env.db.image.fetch(id) map {
|
||||
case None => NotFound
|
||||
case Some(image) =>
|
||||
|
@ -128,7 +129,7 @@ object Main extends LilaController {
|
|||
}
|
||||
}
|
||||
|
||||
val robots = Action { _ =>
|
||||
val robots = Action {
|
||||
Ok {
|
||||
if (Env.api.Net.Crawlable) "User-agent: *\nAllow: /\nDisallow: /game/export"
|
||||
else "User-agent: *\nDisallow: /"
|
||||
|
@ -136,16 +137,12 @@ object Main extends LilaController {
|
|||
}
|
||||
|
||||
def notFound(req: RequestHeader): Fu[Result] =
|
||||
reqToCtx(req) map { implicit ctx =>
|
||||
lila.mon.http.response.code404()
|
||||
NotFound(html.base.notFound())
|
||||
}
|
||||
reqToCtx(req) map notFound
|
||||
|
||||
def authFailed(req: RequestHeader): Fu[Result] =
|
||||
reqToCtx(req) map { implicit ctx =>
|
||||
lila.mon.http.response.code403()
|
||||
Forbidden(html.base.authFailed())
|
||||
}
|
||||
def notFound(ctx: Context): Result = {
|
||||
lila.mon.http.response.code404()
|
||||
NotFound(html.base.notFound()(ctx))
|
||||
}
|
||||
|
||||
def fpmenu = Open { implicit ctx =>
|
||||
Ok(html.base.fpmenu()).fuccess
|
||||
|
|
Loading…
Reference in a new issue