Package

play.api.routing

sird

Permalink

package sird

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")
    }
  }
}
Source
package.scala
Linear Supertypes
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. sird
  2. PathBindableExtractors
  3. RequestMethodExtractors
  4. AnyRef
  5. Any
  1. Hide All
  2. Show all
Visibility
  1. Public
  2. All

Type Members

  1. class OptionalQueryStringParameter extends QueryStringParameterExtractor[Option[String]]

    Permalink
  2. class PathBindableExtractor[T] extends AnyRef

    Permalink

    An extractor that extracts from a String using a play.api.mvc.PathBindable.

  3. trait PathBindableExtractors extends AnyRef

    Permalink

    Extractors that bind types from paths using play.api.mvc.PathBindable.

  4. class PathExtractor extends AnyRef

    Permalink

    The path extractor.

    The path extractor.

    Supported data types that can be extracted from:

    • play.api.mvc.RequestHeader
    • String
    • java.net.URI
    • java.net.URL
  5. type QueryString = Map[String, Seq[String]]

    Permalink

    The query string type

  6. trait QueryStringParameterExtractor[T] extends AnyRef

    Permalink
  7. class RequestMethodExtractor extends AnyRef

    Permalink

    An extractor that extracts requests by method.

  8. trait RequestMethodExtractors extends AnyRef

    Permalink

    Extractors that extract requests by method.

  9. class RequiredQueryStringParameter extends QueryStringParameterExtractor[String]

    Permalink
  10. class SeqQueryStringParameter extends QueryStringParameterExtractor[Seq[String]]

    Permalink
  11. implicit class UrlContext extends AnyRef

    Permalink

Value Members

  1. object &

    Permalink

    Allow multiple parameters to be extracted

  2. val ?: &.type

    Permalink

    Same as &, but for convenience to make the dsl look nicer when extracting query strings

  3. val DELETE: RequestMethodExtractor

    Permalink

    Extracts a DELETE request.

    Extracts a DELETE request.

    Definition Classes
    RequestMethodExtractors
  4. val GET: RequestMethodExtractor

    Permalink

    Extracts a GET request.

    Extracts a GET request.

    Definition Classes
    RequestMethodExtractors
  5. val HEAD: RequestMethodExtractor

    Permalink

    Extracts a HEAD request.

    Extracts a HEAD request.

    Definition Classes
    RequestMethodExtractors
  6. val OPTIONS: RequestMethodExtractor

    Permalink

    Extracts an OPTIONS request.

    Extracts an OPTIONS request.

    Definition Classes
    RequestMethodExtractors
  7. val PATCH: RequestMethodExtractor

    Permalink

    Extracts a PATCH request.

    Extracts a PATCH request.

    Definition Classes
    RequestMethodExtractors
  8. val POST: RequestMethodExtractor

    Permalink

    Extracts a POST request.

    Extracts a POST request.

    Definition Classes
    RequestMethodExtractors
  9. val PUT: RequestMethodExtractor

    Permalink

    Extracts a PUT request.

    Extracts a PUT request.

    Definition Classes
    RequestMethodExtractors
  10. object PathExtractor

    Permalink
  11. object QueryStringParameterExtractor

    Permalink
  12. val bool: PathBindableExtractor[Boolean]

    Permalink

    A boolean extractor.

    A boolean extractor.

    Definition Classes
    PathBindableExtractors
  13. val double: PathBindableExtractor[Double]

    Permalink

    A double extractor.

    A double extractor.

    Definition Classes
    PathBindableExtractors
  14. val float: PathBindableExtractor[Float]

    Permalink

    A float extractor.

    A float extractor.

    Definition Classes
    PathBindableExtractors
  15. val int: PathBindableExtractor[Int]

    Permalink

    An int extractor.

    An int extractor.

    Definition Classes
    PathBindableExtractors
  16. val long: PathBindableExtractor[Long]

    Permalink

    A long extractor.

    A long extractor.

    Definition Classes
    PathBindableExtractors

Inherited from PathBindableExtractors

Inherited from RequestMethodExtractors

Inherited from AnyRef

Inherited from Any

Ungrouped