![JAR search and dependency download from the Maven repository](/logo.png)
skinny.controller.feature.ActionDefinitionFeature.scala Maven / Gradle / Ivy
The newest version!
package skinny.controller.feature
import skinny.controller.ActionDefinition
import org.scalatra._
/**
* Action definitions for this controller.
* These definitions will be used for beforeAction/afterAction's only/except.
*/
trait ActionDefinitionFeature extends ScalatraBase {
/**
* Note: Same action method name should be registered several times.
* For example, put("/members/:id")(...).as('update) and patch("/members/:id")(...).as('update).
*/
protected val actionDefinitions = new scala.collection.mutable.ArrayBuffer[ActionDefinition]
/**
* Adds action definition
*
* @param actionDef action definition
*/
def addActionDefinition(actionDef: ActionDefinition): Unit = {
actionDefinitions += actionDef
}
/**
* Returns action name for this request.
*
* @return action name
*/
def currentActionName: Option[Symbol] = {
actionDefinitions.find { actionDef =>
actionDef.matcher.apply(HttpMethod(request.getMethod), requestPath)
}.map(_.name)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy