org.scalatra

CoreDsl

trait CoreDsl extends Handler with Control with ScalatraContext with ServletApiImplicits

The core Scalatra DSL.

Linear Supertypes
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Hide All
  2. Show all
  1. CoreDsl
  2. ScalatraContext
  3. CookieContext
  4. SessionSupport
  5. ServletApiImplicits
  6. Control
  7. Handler
  8. AnyRef
  9. Any
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def after(transformers: (Route) ⇒ Route*)(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.

  2. abstract def before(transformers: (Route) ⇒ Route*)(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.

  3. abstract def delete(transformers: (Route) ⇒ Route*)(block: ⇒ Any): Route

    See also

    get

  4. 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.

  5. abstract def get(transformers: (Route) ⇒ Route*)(block: ⇒ Any): Route

    The Scalatra DSL core methods take a list of RouteMatcher and a block as the action body.

    The Scalatra DSL core methods take a list of 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 RouteMatcher, so you can write code naturally.

      get("/", request.getRemoteHost == "127.0.0.1") { "Hello localhost!" }
    
  6. abstract def handle(request: HttpServletRequest, res: HttpServletResponse): Unit

    Handles a request and writes to the response.

    Handles a request and writes to the response.

    Definition Classes
    Handler
  7. 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.

  8. abstract def notFound(block: ⇒ Any): Unit

    Defines a block to run if no matching routes are found, or if all matching routes pass.

  9. abstract def options(transformers: (Route) ⇒ Route*)(block: ⇒ Any): Route

    See also

    get

  10. abstract def patch(transformers: (Route) ⇒ Route*)(block: ⇒ Any): Route

    See also

    patch

  11. abstract def post(transformers: (Route) ⇒ Route*)(block: ⇒ Any): Route

    See also

    get

  12. abstract def put(transformers: (Route) ⇒ Route*)(block: ⇒ Any): Route

    See also

    get

  13. implicit abstract def request: HttpServletRequest

    Definition Classes
    ScalatraContext
  14. implicit abstract def response: HttpServletResponse

    Definition Classes
    ScalatraContext
  15. abstract def servletContext: ServletContext

    Definition Classes
    ScalatraContext
  16. 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

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  7. def clone(): AnyRef

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  8. def contentType: String

    Gets the content type of the current response.

    Gets the content type of the current response.

    Definition Classes
    ScalatraContext
  9. def contentType_=(contentType: String): Unit

    Sets the content type of the current response.

    Sets the content type of the current response.

    Definition Classes
    ScalatraContext
  10. implicit def cookieOptions: CookieOptions

    Definition Classes
    CookieContext
  11. def cookies: SweetCookies

    Definition Classes
    CookieContext
  12. implicit def enrichRequest(request: HttpServletRequest): RichRequest

    Definition Classes
    ServletApiImplicits
  13. implicit def enrichResponse(response: HttpServletResponse): RichResponse

    Definition Classes
    ServletApiImplicits
  14. implicit def enrichServletContext(servletContext: ServletContext): RichServletContext

    Definition Classes
    ServletApiImplicits
  15. implicit def enrichSession(session: HttpSession): RichSession

    Definition Classes
    ServletApiImplicits
  16. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  17. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  18. def finalize(): Unit

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  19. 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
  20. 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
  21. final def getClass(): java.lang.Class[_]

    Definition Classes
    AnyRef → Any
  22. def halt(result: ActionResult): Nothing

    Definition Classes
    Control
  23. def halt[T](status: Integer, body: T, headers: Map[String, String], reason: String)(implicit arg0: Manifest[T]): 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

    reason

    the HTTP status reason to set, or null to leave unchanged.

    Definition Classes
    Control
  24. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  25. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  26. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  27. final def notify(): Unit

    Definition Classes
    AnyRef
  28. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  29. def pass(): Nothing

    Immediately exits from the current route.

    Immediately exits from the current route.

    Definition Classes
    Control
  30. implicit def scalatraContext: ScalatraContext

    Attributes
    protected[this]
    Definition Classes
    ScalatraContext
  31. def session(key: Symbol)(implicit request: HttpServletRequest): Any

    Definition Classes
    SessionSupport
  32. def session(key: String)(implicit request: HttpServletRequest): Any

    Definition Classes
    SessionSupport
  33. implicit def session(implicit request: HttpServletRequest): HttpSession

    The current session.

    The current session. Creates a session if none exists.

    Definition Classes
    SessionSupport
  34. def sessionOption(implicit request: HttpServletRequest): Option[HttpSession]

    The current session.

    The current session. If none exists, None is returned.

    Definition Classes
    SessionSupport
  35. def status: Int

    Gets the status code of the current response.

    Gets the status code of the current response.

    Definition Classes
    ScalatraContext
  36. def status_=(code: Int): Unit

    Sets the status code of the current response.

    Sets the status code of the current response.

    Definition Classes
    ScalatraContext
  37. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  38. def toString(): String

    Definition Classes
    AnyRef → Any
  39. def trap(code: Int)(block: ⇒ Any): Unit

    See also

    error

  40. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  41. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  42. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()

Deprecated Value Members

  1. def status(code: Int): Unit

    Definition Classes
    ScalatraContext
    Annotations
    @deprecated
    Deprecated

    (Since version 2.1.0) Use status_=(Int) instead

Inherited from ScalatraContext

Inherited from CookieContext

Inherited from SessionSupport

Inherited from ServletApiImplicits

Inherited from Control

Inherited from Handler

Inherited from AnyRef

Inherited from Any