<commit_before>package skinny.controller

import org.scalatra.Route
import org.scalatra.util.conversion.TypeConverter
import skinny._

/**
 * Routes for Skinny API resource.
 */
trait SkinnyApiResourceRoutes[Id] extends SkinnyApiController with Routes { self: SkinnyApiResourceActions[Id] =>

  /**
   * Set Content-Type response header which is suitable for specified extension.
   */
  protected def setContentTypeFromSkinnyApiResourceExtParam: Unit = {
    params.get("ext").foreach(f => setContentTypeIfAbsent()(Format(f)))
  }

  /**
   * to enable params.getAs[Id]("id")
   */
  implicit val scalatraParamsIdTypeConverter: TypeConverter[String, Id] = new TypeConverter[String, Id] {
    def apply(s: String): Option[Id] = Option(s).map(_.asInstanceOf[Id])
  }

  /**
   * Pass this controller instance implicitly
   * because [[skinny.routing.implicits.RoutesAsImplicits]] expects [[skinny.controller.SkinnyControllerBase]].
   */
  private[this] implicit val skinnyController: SkinnyApiController = this

  // --------------
  // create API
  val createApiUrl = post(s"${resourcesBasePath}.:ext")({
    setContentTypeFromSkinnyApiResourceExtParam
    createApiAction
  }).as('createApi)

  @deprecated("Use createApiUrl instead", since = "1.0.0")
  val createExtUrl = createApiUrl

  def createApiAction = params.get("ext").map {
    case "json" => createResource()(Format.JSON)
    case "xml" => createResource()(Format.XML)
    case _ => haltWithBody(404)
  } getOrElse haltWithBody(404)

  // --------------
  // index API

  val indexApiUrl: Route = get(s"${resourcesBasePath}.:ext")({
    setContentTypeFromSkinnyApiResourceExtParam
    indexApiAction
  }).as('indexApi)
<commit_msg>Fix createApiAction should be protected<commit_after>package skinny.controller

import org.scalatra.Route
import org.scalatra.util.conversion.TypeConverter
import skinny._

/**
 * Routes for Skinny API resource.
 */
trait SkinnyApiResourceRoutes[Id] extends SkinnyApiController with Routes { self: SkinnyApiResourceActions[Id] =>

  /**
   * Set Content-Type response header which is suitable for specified extension.
   */
  protected def setContentTypeFromSkinnyApiResourceExtParam: Unit = {
    params.get("ext").foreach(f => setContentTypeIfAbsent()(Format(f)))
  }

  /**
   * to enable params.getAs[Id]("id")
   */
  implicit val scalatraParamsIdTypeConverter: TypeConverter[String, Id] = new TypeConverter[String, Id] {
    def apply(s: String): Option[Id] = Option(s).map(_.asInstanceOf[Id])
  }

  /**
   * Pass this controller instance implicitly
   * because [[skinny.routing.implicits.RoutesAsImplicits]] expects [[skinny.controller.SkinnyControllerBase]].
   */
  private[this] implicit val skinnyController: SkinnyApiController = this

  // --------------
  // create API
  val createApiUrl = post(s"${resourcesBasePath}.:ext")({
    setContentTypeFromSkinnyApiResourceExtParam
    createApiAction
  }).as('createApi)

  @deprecated("Use createApiUrl instead", since = "1.0.0")
  val createExtUrl = createApiUrl

  protected def createApiAction = params.get("ext").map {
    case "json" => createResource()(Format.JSON)
    case "xml" => createResource()(Format.XML)
    case _ => haltWithBody(404)
  } getOrElse haltWithBody(404)

  // --------------
  // index API

  val indexApiUrl: Route = get(s"${resourcesBasePath}.:ext")({
    setContentTypeFromSkinnyApiResourceExtParam
    indexApiAction
  }).as('indexApi)

{'fraction_non_alphanumeric': 0.13718622300058378, 'fraction_numerical': 0.005253940455341506, 'mean_word_length': 4.114925373134328, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '5453338', 'n_tokens_mistral': 1070, 'n_tokens_neox': 1027, 'n_words': 217}