def apply()

in server/src/main/scala/com/twitter/server/handler/LintHandler.scala [18:36]


  def apply(req: Request): Future[Response] =
    if (expectsHtml(req) && !expectsJson(req)) htmlResponse(req) else jsonResponse(req)

  private[this] def htmlResponse(req: Request): Future[Response] = {
    // first, run the rules.
    val rules = GlobalRules.get.iterable.toSeq
    val (oks, nots) = rules
      .map(rule => rule -> rule())
      .partition { case (_, res) => res.isEmpty }

    // render the ui and respond
    val view = new LintView(rules, oks.map(o => o._1), nots)
    val rendered = view()
    newResponse(
      // note: contentType must be explicit here because of `IndexView.isFragment`
      contentType = "text/html;charset=UTF-8",
      content = Buf.Utf8(rendered)
    )
  }