org.scalatra

package org.scalatra

Type members

Classlikes

object Accepted
case class ActionResult(status: Int, body: Any, headers: Map[String, String])
object ApiFormats
Companion:
class
trait ApiFormats extends ScalatraBase

Adds support for mapping and inferring formats to content types.

Adds support for mapping and inferring formats to content types.

$ - Provides a request-scoped format variable $ - Maps formats to content types and vice versa $ - Augments the content-type inferrer to use the format

Companion:
object
abstract class AsyncResult(implicit val scalatraContext: ScalatraContext) extends ScalatraContext
object BadGateway
object BadRequest
final class BooleanBlockRouteMatcher(block: => Boolean) extends RouteMatcher

A route matcher on a boolean condition. Does not extract any route parameters.

A route matcher on a boolean condition. Does not extract any route parameters.

object Conflict
case object Connect extends HttpMethod

Represents an HTTP content encoding.

Represents an HTTP content encoding.

Companion:
object
Companion:
class
trait ContentEncodingSupport extends Handler

Scalatra handler for gzipped responses.

Scalatra handler for gzipped responses.

case class ContentNegotiation[T](value: T, q: Float)

Represents the value of a content negotiation header.

Represents the value of a content negotiation header.

Companion:
object

Defines type classes and helper methods for well known content-negotiation headers.

Defines type classes and helper methods for well known content-negotiation headers.

Companion:
class
trait Control

A collection of methods that affect the control flow of routes.

A collection of methods that affect the control flow of routes.

object Cookie
Companion:
class
case class Cookie(name: String, value: String)(implicit cookieOptions: CookieOptions)
Companion:
object
case class CookieOptions(domain: String, path: String, maxAge: Int, secure: Boolean, comment: String, httpOnly: Boolean, version: Int, encoding: String)
trait CoreDsl extends Handler with Control with ScalatraContext with ServletApiImplicits

The core Scalatra DSL.

The core Scalatra DSL.

Companion:
class
trait CorsSupport extends Handler with Initializable
Companion:
object
object Created
Companion:
class

Provides cross-site request forgery protection.

Provides cross-site request forgery protection.

Adds a before filter. If a request is determined to be forged, the handleForgery() hook is invoked. Otherwise, a token for the next request is prepared with prepareCsrfToken.

Companion:
object
case object Delete extends HttpMethod

The Scalatra DSL requires a dynamically scoped request and response.

The Scalatra DSL requires a dynamically scoped request and response.

case class ExtensionMethod(name: String) extends HttpMethod
class FlashMap extends Serializable

A FlashMap is the data structure used by org.scalatra.FlashMapSupport to allow passing temporary values between sequential actions.

A FlashMap is the data structure used by org.scalatra.FlashMapSupport to allow passing temporary values between sequential actions.

As of Scalatra 2.7.x, it does not directly inherit Map.

See also:

FlashMapSupport

Companion:
class
trait FlashMapSupport extends Handler

Allows an action to set key-value pairs in a transient state that is accessible only to the next action and is expired immediately after that. This is especially useful when using the POST-REDIRECT-GET pattern to trace the result of an operation.

Allows an action to set key-value pairs in a transient state that is accessible only to the next action and is expired immediately after that. This is especially useful when using the POST-REDIRECT-GET pattern to trace the result of an operation.

post("/article/create") {
 // create session
 flash("notice") = "article created successfully"
 redirect("/home")
}
get("/home") {
 // this will access the value set in previous action
 stuff_with(flash("notice"))
}
See also:

FlashMap

Companion:
object
object Forbidden
object Found
object GenerateId
case object Get extends HttpMethod
object Gone
case class HaltException(status: Option[Int], headers: Map[String, String], body: Any) extends Throwable with NoStackTrace
case object Head extends HttpMethod
case object Http extends Scheme
object Http10 extends HttpVersion
object Http11 extends HttpVersion
sealed trait HttpMethod
Companion:
object
object HttpMethod
Companion:
class
abstract class HttpVersion(val protocolName: String, val majorVersion: Int, val minorVersion: Int, val keepAliveDefault: Boolean) extends Ordered[HttpVersion]
case object Https extends Scheme
object IMUsed
object Locked
case class MatchedRoute(action: Action, multiParams: MultiParams)

An action and the multi-map of route parameters to invoke it with.

An action and the multi-map of route parameters to invoke it with.

Companion:
class
trait MethodOverride extends Handler with ServletApiImplicits

Mixin for clients that only support a limited set of HTTP verbs. If the request is a POST and the _method request parameter is set, the value of the _method parameter is treated as the request's method.

Mixin for clients that only support a limited set of HTTP verbs. If the request is a POST and the _method request parameter is set, the value of the _method parameter is treated as the request's method.

Companion:
object
object NoContent
object NotFound
object Ok
case object Options extends HttpMethod
class PassException extends Throwable with NoStackTrace
case object Patch extends HttpMethod
case class PathPattern(regex: Regex, captureGroupNames: List[String])

A path pattern optionally matches a request path and extracts path parameters.

A path pattern optionally matches a request path and extracts path parameters.

Parses a string into a path pattern for routing.

Parses a string into a path pattern for routing.

Companion:
object
Companion:
class
final class PathPatternRouteMatcher(pattern: PathPattern) extends RouteMatcher
case object Post extends HttpMethod
case object Put extends HttpMethod

Path pattern parser based on Rack::Mount::Strexp, which is used by Rails.

Path pattern parser based on Rack::Mount::Strexp, which is used by Rails.

Companion:
object
final class RailsRouteMatcher(pattern: String) extends RouteMatcher with ReversibleRouteMatcher

An implementation of Rails' path pattern syntax

An implementation of Rails' path pattern syntax

trait RegexPathPatternParser extends PathPatternParser with RegexParsers
final class RegexRouteMatcher(regex: Regex) extends RouteMatcher

A route matcher for regular expressions. Useful for cases that are more complex than are supported by Sinatra- or Rails-style routes.

A route matcher for regular expressions. Useful for cases that are more complex than are supported by Sinatra- or Rails-style routes.

A route matcher from which a URI can be generated from route parameters.

A route matcher from which a URI can be generated from route parameters.

case class Route(routeMatchers: Seq[RouteMatcher], action: Action, contextPath: HttpServletRequest => String, metadata: Map[Symbol, Any])

A route is a set of matchers and an action. A route is considered to match if all of its route matchers return Some. If a route matches, its action may be invoked. The route parameters extracted by the matchers are made available to the action.

A route is a set of matchers and an action. A route is considered to match if all of its route matchers return Some. If a route matches, its action may be invoked. The route parameters extracted by the matchers are made available to the action.

Companion:
object
object Route
Companion:
class

A route matcher is evaluated in the context it was created and returns a a (possibly empty) multi-map of parameters if the route is deemed to match.

A route matcher is evaluated in the context it was created and returns a a (possibly empty) multi-map of parameters if the route is deemed to match.

Companion:
class
Companion:
object
Companion:
class

The base implementation of the Scalatra DSL. Intended to be portable to all supported backends.

The base implementation of the Scalatra DSL. Intended to be portable to all supported backends.

Companion:
object
Companion:
class
class ScalatraException(message: String) extends Exception
trait ScalatraFilter extends Filter with ServletBase

An implementation of the Scalatra DSL in a filter. You may prefer a filter to a ScalatraServlet if:

An implementation of the Scalatra DSL in a filter. You may prefer a filter to a ScalatraServlet if:

$ - you are sharing a URL space with another servlet or filter and want to delegate unmatched requests. This is very useful when migrating legacy applications one page or resource at a time.

Unlike a ScalatraServlet, does not send 404 or 405 errors on non-matching routes. Instead, it delegates to the filter chain.

If in doubt, extend ScalatraServlet instead.

See also:

ScalatraServlet

class ScalatraParams(val multiMap: Map[String, Seq[String]]) extends MultiMapHeadView[String, String]

Add some implicits

Add some implicits

Companion:
object
trait ScalatraServlet extends HttpServlet with ServletBase with Initializable

An implementation of the Scalatra DSL in a servlet. This is the recommended base trait for most Scalatra applications. Use a servlet if:

An implementation of the Scalatra DSL in a servlet. This is the recommended base trait for most Scalatra applications. Use a servlet if:

$ - your Scalatra routes run in a subcontext of your web application. $ - you want Scalatra to have complete control of unmatched requests. $ - you think you want a filter just for serving static content with the default servlet; ScalatraServlet can do this too $ - you don't know the difference

See also:

ScalatraFilter

sealed trait Scheme
object SeeOther

This trait provides session support for stateful applications.

This trait provides session support for stateful applications.

A Sinatra-compatible route path pattern parser.

A Sinatra-compatible route path pattern parser.

Companion:
object
final class SinatraRouteMatcher(pattern: String) extends RouteMatcher with ReversibleRouteMatcher

An implementation of Sinatra's path pattern syntax.

An implementation of Sinatra's path pattern syntax.

trait SslRequirement extends Handler with ServletApiImplicits

Redirects unsecured requests to the corresponding secure URL.

Redirects unsecured requests to the corresponding secure URL.

final class StatusCodeRouteMatcher(codes: Range, responseStatus: => Int) extends RouteMatcher
class SweetCookies(reqCookies: Map[String, String], response: HttpServletResponse) extends ServletApiImplicits
case object Trace extends HttpMethod
object UriDecoder

Adds support for generating URIs from routes and their params.

Adds support for generating URIs from routes and their params.

object UseProxy
Companion:
object
Companion:
class

Value members

Inherited methods

def halt(result: ActionResult): Nothing
Inherited from:
Control
def halt[T](status: Integer, body: T, headers: Map[String, String]): Nothing

Immediately halts processing of a request. Can be called from either a before filter or a route.

Immediately halts processing of a request. Can be called from either a before filter or a route.

Value parameters:
body

a result to render through the render pipeline as the body

headers

headers to add to the response

status

the status to set on the response, or null to leave the status unchanged.

Inherited from:
Control
def pass(): Nothing

Immediately exits from the current route.

Immediately exits from the current route.

Inherited from:
Control

Concrete fields

val EnvironmentKey: String
val MultiParamsKey: String