org.scalatra

CoreDsl

trait CoreDsl extends AnyRef

The core DSL of a Scalatra application.

Linear Supertypes
AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. CoreDsl
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def after(routeMatchers: RouteMatcher*)(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(routeMatchers: RouteMatcher*)(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(routeMatchers: RouteMatcher*)(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(routeMatchers: RouteMatcher*)(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.ScalatraKernel.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!" }
  6. abstract def halt[T](status: Integer, body: T, headers: Map[String, String], reason: String)(implicit arg0: Manifest[T]): Nothing

    Immediately halts the current action.

    Immediately halts the current action. If called within a before filter, prevents the action from executing. Any matching after filters will still execute.

    status

    set as the response's HTTP status code. Ignored if null.

    body

    rendered to the response body through the response pipeline.

    headers

    added as headers to the response. Previously set headers are retained

    reason

    set as the HTTP status reason. Ignored if null or if status is null.

  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 multiParams: MultiParams

    A multi-map of the current parameters.

    A multi-map of the current parameters. Parameters may come from: - the query string - the POST body - the route matchers of the currently executing route

    The map has a default value of Seq.empty.

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

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

  10. abstract def options(routeMatchers: RouteMatcher*)(block: ⇒ Any): Route

    See also

    get

  11. abstract def params: Map[String, String]

    A map of the current parameters.

    A map of the current parameters. The map contains the head of every non-empty value in multiParams.

  12. abstract def pass(): Unit

    Immediately passes execution to the next matching route.

  13. abstract def patch(routeMatchers: RouteMatcher*)(block: ⇒ Any): Route

    See also

    patch

  14. abstract def post(routeMatchers: RouteMatcher*)(block: ⇒ Any): Route

    See also

    get

  15. abstract def put(routeMatchers: RouteMatcher*)(block: ⇒ Any): Route

    See also

    get

  16. implicit abstract def request: HttpServletRequest

    The current request

  17. implicit abstract def response: HttpServletResponse

    The current response.

  18. implicit abstract def servletContext: ServletContext

    The current servlet context

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[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  8. def contentType: String

    Gets the content type of the current response.

  9. def contentType_=(contentType: String): Unit

    Sets the content type of the current response.

  10. final def eq(arg0: AnyRef): Boolean

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

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

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  13. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  14. def hashCode(): Int

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

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

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

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

    Definition Classes
    AnyRef
  19. def redirect(uri: String): Unit

    Sends a redirect response and immediately halts the current action.

  20. implicit def session: HttpSession

    The current HTTP session.

    The current HTTP session. Creates a session if none exists.

  21. def sessionOption: Option[HttpSession]

    The current HTTP session.

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

  22. def status(code: Int): Unit

    Sets the status code of the current response.

  23. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  24. def toString(): String

    Definition Classes
    AnyRef → Any
  25. final def wait(): Unit

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws()

Deprecated Value Members

  1. final def afterAll(block: ⇒ Any): Unit

    Annotations
    @deprecated
    Deprecated

    Use after() { ... }

  2. final def afterSome(routeMatchers: RouteMatcher*)(block: ⇒ Any): Unit

    Annotations
    @deprecated
    Deprecated

    Use after(RouteMatcher*) { ... }

  3. final def beforeAll(block: ⇒ Any): Unit

    Annotations
    @deprecated
    Deprecated

    Use before() { ... }

  4. final def beforeSome(routeMatchers: RouteMatcher*)(block: ⇒ Any): Unit

    Annotations
    @deprecated
    Deprecated

    Use before(RouteMatcher*) { ... }

Inherited from AnyRef

Inherited from Any

Ungrouped