<commit_before>package com.twitter.server

import com.twitter.app.App
import com.twitter.finagle.client.ClientRegistry
import com.twitter.finagle.http.HttpMuxer
import com.twitter.finagle.server.ServerRegistry
import com.twitter.finagle.stats.NullStatsReceiver
import com.twitter.finagle.tracing.NullTracer
import com.twitter.finagle.{Http, ListeningServer, NullServer, param, Service}
import com.twitter.server.util.HttpUtils
import com.twitter.server.view.{IndexView, NotFoundView}
import com.twitter.util.Monitor
import java.net.InetSocketAddress
import java.util.logging.Logger

object AdminHttpServer {
  /**
   * Represents an element which can be routed to via the admin http server.
   *
   * @param path The path used to access the route. A request
   * is routed to the path as per the [[com.twitter.finagle.http.HttpMuxer]]
   * spec.
   *
   * @param handler The service which requests are routed to.
   *
   * @param alias A short name used to identify the route when listed in
   * index.
   *
   * @param group A grouping used to organize the route in the
   * admin server pages. Routes with the same grouping are displayed
   * together in the admin server pages.
   *
   * @param includeInIndex Indicates whether the route is included
   * as part of the admin server index.
   */
  case class Route(
    path: String,
    handler: Service[HttpUtils.Request, HttpUtils.Response],
    alias: String,
    group: Option[String],
    includeInIndex: Boolean)
}

trait AdminHttpServer { self: App =>
  import AdminHttpServer._

  def defaultHttpPort: Int = 9990
  val adminPort = flag("admin.port", new InetSocketAddress(defaultHttpPort), "Admin http server port")

  @volatile protected var adminHttpServer: ListeningServer = NullServer

  protected def routes: Seq[Route] = Nil

  premain {
    // a logger used to log all sync and async exceptions
    // that occur in the admin server.<commit_msg>Fix up static site server_info<commit_after>package com.twitter.server

import com.twitter.app.App
import com.twitter.finagle.client.ClientRegistry
import com.twitter.finagle.http.{Response, Request, HttpMuxer}
import com.twitter.finagle.server.ServerRegistry
import com.twitter.finagle.stats.NullStatsReceiver
import com.twitter.finagle.tracing.NullTracer
import com.twitter.finagle.{Filter, Http, ListeningServer, NullServer, param, Service}
import com.twitter.server.util.HttpUtils
import com.twitter.server.view.{IndexView, NotFoundView}
import com.twitter.util.Monitor
import java.net.InetSocketAddress
import java.util.logging.Logger
import org.jboss.netty.handler.codec.http.{HttpResponse, HttpRequest}

object AdminHttpServer {
  /**
   * Represents an element which can be routed to via the admin http server.
   *
   * @param path The path used to access the route. A request
   * is routed to the path as per the [[com.twitter.finagle.http.HttpMuxer]]
   * spec.
   *
   * @param handler The service which requests are routed to.
   *
   * @param alias A short name used to identify the route when listed in
   * index.
   *
   * @param group A grouping used to organize the route in the
   * admin server pages. Routes with the same grouping are displayed
   * together in the admin server pages.
   *
   * @param includeInIndex Indicates whether the route is included
   * as part of the admin server index.
   */
  case class Route(
    path: String,
    handler: Service[HttpUtils.Request, HttpUtils.Response],
    alias: String,
    group: Option[String],
    includeInIndex: Boolean)

  /**
   * Create a Route using a Finagle service interface
   */
  def mkRoute(
    path: String,
    handler: Service[Request, Response],
    alias: String,
    group: Option[String],
    includeInIndex: Boolean
  ): Route = {
    val nettyToFinagle = Filter.mk[HttpRequest, HttpResponse, Request, Response] { (req, service) =>
      service(Request(req)) map { _.httpResponse }
    }

    Route(path, nettyToFinagle andThen handler, alias, group, includeInIndex)
  }

}

trait AdminHttpServer { self: App =>
  import AdminHttpServer._

  def defaultHttpPort: Int = 9990
  val adminPort = flag("admin.port", new InetSocketAddress(defaultHttpPort), "Admin http server port")

  @volatile protected var adminHttpServer: ListeningServer = NullServer

  protected def routes: Seq[Route] = Nil

  premain {
    // a logger used to log all sync and async exceptions
    // that occur in the admin server.
{'fraction_non_alphanumeric': 0.08355978260869565, 'fraction_numerical': 0.0018115942028985507, 'mean_word_length': 3.816793893129771, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6537423', 'n_tokens_mistral': 1281, 'n_tokens_neox': 1251, 'n_words': 435}