play.api.routing

sird

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
Learn more about member selection
Visibility
  1. Public
  2. All

Type Members

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

  2. class PathBindableExtractor[T] extends AnyRef

    An extractor that extracts from a String using a PathBindable.

  3. trait PathBindableExtractors extends AnyRef

    Extractors that bind types from paths using PathBindable.

  4. class PathExtractor extends AnyRef

    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]]

    The query string type

  6. trait QueryStringParameterExtractor[T] extends AnyRef

  7. class RequestMethodExtractor extends AnyRef

    An extractor that extracts requests by method.

  8. trait RequestMethodExtractors extends AnyRef

    Extractors that extract requests by method.

  9. class RequiredQueryStringParameter extends QueryStringParameterExtractor[String]

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

  11. implicit class UrlContext extends AnyRef

Value Members

  1. object &

    Allow multiple parameters to be extracted

  2. val ?: &.type

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

  3. val DELETE: RequestMethodExtractor

    Extracts a DELETE request.

    Extracts a DELETE request.

    Definition Classes
    RequestMethodExtractors
  4. val GET: RequestMethodExtractor

    Extracts a GET request.

    Extracts a GET request.

    Definition Classes
    RequestMethodExtractors
  5. val HEAD: RequestMethodExtractor

    Extracts a HEAD request.

    Extracts a HEAD request.

    Definition Classes
    RequestMethodExtractors
  6. val OPTIONS: RequestMethodExtractor

    Extracts an OPTIONS request.

    Extracts an OPTIONS request.

    Definition Classes
    RequestMethodExtractors
  7. val PATCH: RequestMethodExtractor

    Extracts a PATCH request.

    Extracts a PATCH request.

    Definition Classes
    RequestMethodExtractors
  8. val POST: RequestMethodExtractor

    Extracts a POST request.

    Extracts a POST request.

    Definition Classes
    RequestMethodExtractors
  9. val PUT: RequestMethodExtractor

    Extracts a PUT request.

    Extracts a PUT request.

    Definition Classes
    RequestMethodExtractors
  10. object PathExtractor

  11. object QueryStringParameterExtractor

  12. val bool: PathBindableExtractor[Boolean]

    A boolean extractor.

    A boolean extractor.

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

    A double extractor.

    A double extractor.

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

    A float extractor.

    A float extractor.

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

    An int extractor.

    An int extractor.

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

    A long extractor.

    A long extractor.

    Definition Classes
    PathBindableExtractors

Inherited from PathBindableExtractors

Inherited from RequestMethodExtractors

Inherited from AnyRef

Inherited from Any

Ungrouped