trait CoreDsl extends Handler with Control with ScalatraContext with ServletApiImplicits
The core Scalatra DSL.
- Alphabetic
- By Inheritance
- CoreDsl
- ScalatraContext
- CookieContext
- SessionSupport
- ServletApiImplicits
- Control
- Handler
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Abstract Value Members
- abstract def after(transformers: RouteTransformer*)(block: => Any): Unit
Adds a filter to run after the route.
Adds a filter to run after the route. The filter only runs if each routeMatcher returns Some. If the routeMatchers list is empty, the filter runs for all routes.
- abstract def before(transformers: RouteTransformer*)(block: => Any): Unit
Adds a filter to run before the route.
Adds a filter to run before the route. The filter only runs if each routeMatcher returns Some. If the routeMatchers list is empty, the filter runs for all routes.
- abstract def delete(transformers: RouteTransformer*)(block: => Any): Route
- See also
get
- abstract def error(handler: ErrorHandler): Unit
Defines an error handler for exceptions thrown in either the before block or a route action.
Defines an error handler for exceptions thrown in either the before block or a route action.
If the error handler does not match, the result falls through to the previously defined error handler. The default error handler simply rethrows the exception.
The error handler is run before the after filters, and the result is rendered like a standard response. It is the error handler's responsibility to set any appropriate status code.
- abstract def get(transformers: RouteTransformer*)(block: => Any): Route
The Scalatra DSL core methods take a list of org.scalatra.RouteMatcher and a block as the action body.
The Scalatra DSL core methods take a list of org.scalatra.RouteMatcher and a block as the action body. The return value of the block is rendered through the pipeline and sent to the client as the response body.
See org.scalatra.ScalatraBase#renderResponseBody for the detailed behaviour and how to handle your response body more explicitly, and see how different return types are handled.
The block is executed in the context of a CoreDsl instance, so all the methods defined in this trait are also available inside the block.
get("/") { <form action="/echo"> <label>Enter your name</label> <input type="text" name="name"/> </form> } post("/echo") { "hello {params('name)}!" }
ScalatraKernel provides implicit transformation from boolean blocks, strings and regular expressions to org.scalatra.RouteMatcher, so you can write code naturally.
get("/", request.getRemoteHost == "127.0.0.1") { "Hello localhost!" }
- abstract def handle(request: HttpServletRequest, res: HttpServletResponse): Unit
- Definition Classes
- Handler
- abstract def head(transformers: RouteTransformer*)(block: => Any): Route
- See also
head
- abstract def methodNotAllowed(block: (Set[HttpMethod]) => Any): Unit
Defines a block to run if matching routes are found only for other methods.
Defines a block to run if matching routes are found only for other methods. The set of matching methods is passed to the block.
- abstract def notFound(block: => Any): Unit
Defines a block to run if no matching routes are found, or if all matching routes pass.
- abstract def options(transformers: RouteTransformer*)(block: => Any): Route
- See also
get
- abstract def patch(transformers: RouteTransformer*)(block: => Any): Route
- See also
patch
- abstract def post(transformers: RouteTransformer*)(block: => Any): Route
- See also
get
- abstract def put(transformers: RouteTransformer*)(block: => Any): Route
- See also
get
- implicit abstract def request: HttpServletRequest
- Definition Classes
- ScalatraContext
- implicit abstract def response: HttpServletResponse
- Definition Classes
- ScalatraContext
- abstract def servletContext: ServletContext
- Definition Classes
- ScalatraContext
- abstract def trap(codes: Range)(block: => Any): Unit
Error handler for HTTP response status code range.
Error handler for HTTP response status code range. You can intercept every response code previously specified with #status or even generic 404 error.
trap(403) { "You are not authorized" } }*
}}
Concrete Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def contentType: String
Gets the content type of the current response.
Gets the content type of the current response.
- Definition Classes
- ScalatraContext
- def contentType_=(contentType: String): Unit
Sets the content type of the current response.
Sets the content type of the current response.
- Definition Classes
- ScalatraContext
- implicit def cookieOptions: CookieOptions
- Definition Classes
- CookieContext
- def cookies(implicit request: HttpServletRequest): SweetCookies
- Definition Classes
- CookieContext
- implicit def enrichRequest(request: HttpServletRequest): RichRequest
- Definition Classes
- ServletApiImplicits
- implicit def enrichResponse(response: HttpServletResponse): RichResponse
- Definition Classes
- ServletApiImplicits
- implicit def enrichServletContext(servletContext: ServletContext): RichServletContext
- Definition Classes
- ServletApiImplicits
- implicit def enrichSession(session: HttpSession): RichSession
- Definition Classes
- ServletApiImplicits
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- def format_=(formatValue: String): Unit
Explicitly sets the request-scoped format.
Explicitly sets the request-scoped format. This takes precedence over whatever was inferred from the request.
- Definition Classes
- ScalatraContext
- def format_=(formatValue: Symbol): Unit
Explicitly sets the request-scoped format.
Explicitly sets the request-scoped format. This takes precedence over whatever was inferred from the request.
- Definition Classes
- ScalatraContext
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def halt(result: ActionResult): Nothing
- Definition Classes
- Control
- def halt[T](status: Integer = null, body: T = (), headers: Map[String, String] = Map.empty): Nothing
Immediately halts processing of a request.
Immediately halts processing of a request. Can be called from either a before filter or a route.
- status
the status to set on the response, or null to leave the status unchanged.
- body
a result to render through the render pipeline as the body
- headers
headers to add to the response
- Definition Classes
- Control
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def pass(): Nothing
Immediately exits from the current route.
Immediately exits from the current route.
- Definition Classes
- Control
- implicit def scalatraContext: ScalatraContext
- Attributes
- protected[this]
- Definition Classes
- ScalatraContext
- def session(key: String)(implicit request: HttpServletRequest): Any
- Definition Classes
- SessionSupport
- implicit def session(implicit request: HttpServletRequest): HttpSession
The current session.
The current session. Creates a session if none exists.
- Definition Classes
- SessionSupport
- def sessionOption(implicit request: HttpServletRequest): Option[HttpSession]
The current session.
The current session. If none exists, None is returned.
- Definition Classes
- SessionSupport
- def status: Int
Gets the status code of the current response.
Gets the status code of the current response.
- Definition Classes
- ScalatraContext
- def status_=(code: Int): Unit
Sets the status code of the current response.
Sets the status code of the current response.
- Definition Classes
- ScalatraContext
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- def trap(code: Int)(block: => Any): Unit
- See also
error
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()