play.api.routing

Members list

Packages

The Play "String Interpolating Routing DSL", sird for short.

The Play "String Interpolating Routing DSL", sird for short.

This provides:

  • Extractors for requests that extract requests by method, eg GET, POST etc.
  • A string interpolating path extractor
  • Extractors for binding parameters from paths to various types, eg int, long, double, bool.

The request method extractors return the original request for further extraction.

The path extractor supports three kinds of extracted values:

  • Path segment values. This is the default, eg p"/foo/$id". The value will be URI decoded, and may not traverse /'s.
  • Full path values. This can be indicated by post fixing the value with a *, eg p"/assets/$path*". The value will not be URI decoded, as that will make it impossible to distinguish between / and %2F.
  • Regex values. This can be indicated by post fixing the value with a regular expression enclosed in angle brackets. For example, p"/foo/$id<[0-9]+>. The value will not be URI decoded.

The extractors for primitive types are merely provided for convenience, for example, p"/foo/${int(id)}" will extract id as an integer. If id is not an integer, the match will simply fail.

Example usage:

import play.api.routing.sird._
import play.api.routing._
import play.api.mvc._

Router.from {
  case GET(p"/hello/$to") => Action {
    Results.Ok(s"Hello $to")
  }
  case PUT(p"/api/items/${int(id)}") => Action.async { req =>
    Items.save(id, req.body.json.as[Item]).map { _ =>
      Results.Ok(s"Saved item $id")
    }
  }
}

Attributes

Type members

Classlikes

case class HandlerDef(classLoader: ClassLoader, routerPackage: String, controller: String, method: String, parameterTypes: Seq[Class[_]], verb: String, path: String, comments: String, modifiers: Seq[String]) extends HandlerDef

Information about a Handler, especially useful for loading the handler with reflection.

Information about a Handler, especially useful for loading the handler with reflection.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class HandlerDef
class Object
trait Matchable
class Any
Show all
case class JavaScriptReverseRoute(name: String, f: String)

A JavaScript reverse route

A JavaScript reverse route

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
trait Router

A router.

A router.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
Self type
object Router

Utilities for routing.

Utilities for routing.

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
Router.type
trait SimpleRouter extends Router

A simple router that implements the withPrefix and documentation methods for you.

A simple router that implements the withPrefix and documentation methods for you.

Attributes

Companion
object
Supertypes
trait Router
class Object
trait Matchable
class Any
Known subtypes
Self type
object SimpleRouter

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
class SimpleRouterImpl(routesProvider: => Routes) extends SimpleRouter

Attributes

Supertypes
trait SimpleRouter
trait Router
class Object
trait Matchable
class Any