org.scalatra.route.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scalatra_2.8.2.RC1 Show documentation
Show all versions of scalatra_2.8.2.RC1 Show documentation
The core Scalatra framework
The newest version!
package org.scalatra
import ScalatraKernel.{Action, MultiParams}
import util.MultiMap
case class Route(
routeMatchers: Iterable[RouteMatcher],
action: Action,
contextPath: () => String = () => ""
)
{
def apply(): Option[MatchedRoute] = {
routeMatchers.foldLeft(Option(MultiMap())) {
(acc: Option[MultiParams], routeMatcher: RouteMatcher) => for {
routeParams <- acc
matcherParams <- routeMatcher()
} yield routeParams ++ matcherParams
} map { routeParams => MatchedRoute(action, routeParams) }
}
lazy val reversibleMatcher: Option[RouteMatcher] =
routeMatchers find (_.isInstanceOf[ReversibleRouteMatcher])
lazy val isReversible: Boolean = !reversibleMatcher.isEmpty
override def toString: String = routeMatchers mkString " "
}
case class MatchedRoute(action: Action, multiParams: MultiParams)
© 2015 - 2024 Weber Informatics LLC | Privacy Policy