<commit_before>package play.api.mini

import play.api.GlobalSettings
import play.api.mvc._
import play.api.mvc.Results._

/**
 * an interface that a mini application needs to implement
 */
trait Application {
  def dispatcher: Map[String, Action[_]]
}

/**
 * provides a simple way to use play as a simple http layer (using scala)
 *
 * example:
 * in the global package name space
 * {{{
 * object Global extends play.api.mini.Setup[com.example.App]
 * }}}
 * and then in your own package
 * {{{
 * class App extends play.api.mini.Application {
 *   def dispatcher: Map[String,Action[_]] =  Map("/coco" -> Action{ Ok(<h1>It works!</h1>).as("text/html") })
 * }
 * }}}
 */
class Setup[T <: Application](implicit m: Manifest[T]) extends GlobalSettings {

  private lazy val routes: Map[String, Action[_]] = {
      val cl = Thread.currentThread().getContextClassLoader()
      try {
        val clazz = m.erasure
        clazz.getMethod("dispatcher").invoke(clazz.newInstance()).asInstanceOf[Map[String, Action[_]]]
      } catch { case (ex: Exception) => throw new Exception("could not find a MiniApplication object that extends Mini:" + ex.toString) }
  }

  override def onRouteRequest(request: RequestHeader): Option[Action[_]] = request match {
    case _ => routes.get(request.path)
  }

}
<commit_msg>fix error message<commit_after>package play.api.mini

import play.api.GlobalSettings
import play.api.mvc._
import play.api.mvc.Results._

/**
 * an interface that a mini application needs to implement
 */
trait Application {
  def dispatcher: Map[String, Action[_]]
}

/**
 * provides a simple way to use play as a simple http layer (using scala)
 *
 * example:
 * in the global package name space
 * {{{
 * object Global extends play.api.mini.Setup[com.example.App]
 * }}}
 * and then in your own package
 * {{{
 * class App extends play.api.mini.Application {
 *   def dispatcher: Map[String,Action[_]] =  Map("/coco" -> Action{ Ok(<h1>It works!</h1>).as("text/html") })
 * }
 * }}}
 */
class Setup[T <: Application](implicit m: Manifest[T]) extends GlobalSettings {

  private lazy val routes: Map[String, Action[_]] = {
      val cl = Thread.currentThread().getContextClassLoader()
      try {
        val clazz = m.erasure
        clazz.getMethod("dispatcher").invoke(clazz.newInstance()).asInstanceOf[Map[String, Action[_]]]
      } catch { case (ex: Exception) => throw new Exception("could not find Application:" + ex.toString) }
  }

  override def onRouteRequest(request: RequestHeader): Option[Action[_]] = request match {
    case _ => routes.get(request.path)
  }

}

{'fraction_non_alphanumeric': 0.14224971008890608, 'fraction_numerical': 0.0015461925009663702, 'mean_word_length': 3.7925925925925927, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, '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': '6537216', 'n_tokens_mistral': 797, 'n_tokens_neox': 786, 'n_words': 221}