org.scalatra

ApiFormats

trait ApiFormats extends ScalatraKernel

go to: companion
linear super types: ScalatraKernel, ServletApiImplicits, Initializable, CoreDsl, Handler, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Hide All
  2. Show all
  1. ApiFormats
  2. ScalatraKernel
  3. ServletApiImplicits
  4. Initializable
  5. CoreDsl
  6. Handler
  7. AnyRef
  8. Any
Visibility
  1. Public
  2. All
Impl.
  1. Concrete
  2. Abstract

Type Members

  1. type Config

    attributes: abstract
    definition classes: Initializable
  2. case class HaltException (status: Option[Int], reason: Option[String], headers: Map[String, String], body: Any) extends RuntimeException with Product

    attributes: protected
  3. class PassException extends RuntimeException

    attributes: protected[scalatra]

Value Members

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

    attributes: final
    definition classes: AnyRef
  2. def != (arg0: Any) : Boolean

    o != arg0 is the same as !(o == (arg0)).

    o != arg0 is the same as !(o == (arg0)).

    arg0

    the object to compare against this object for dis-equality.

    returns

    false if the receiver object is equivalent to the argument; true otherwise.

    attributes: final
    definition classes: Any
  3. def ## () : Int

    attributes: final
    definition classes: AnyRef → Any
  4. def $asInstanceOf [T0] () : T0

    attributes: final
    definition classes: AnyRef
  5. def $isInstanceOf [T0] () : Boolean

    attributes: final
    definition classes: AnyRef
  6. def == (arg0: AnyRef) : Boolean

    o == arg0 is the same as if (o eq null) arg0 eq null else o.equals(arg0).

    o == arg0 is the same as if (o eq null) arg0 eq null else o.equals(arg0).

    arg0

    the object to compare against this object for equality.

    returns

    true if the receiver object is equivalent to the argument; false otherwise.

    attributes: final
    definition classes: AnyRef
  7. def == (arg0: Any) : Boolean

    o == arg0 is the same as o.equals(arg0).

    o == arg0 is the same as o.equals(arg0).

    arg0

    the object to compare against this object for equality.

    returns

    true if the receiver object is equivalent to the argument; false otherwise.

    attributes: final
    definition classes: Any
  8. val _params : MultiMapHeadView[String, String] with MapWithIndifferentAccess[String]

    attributes: protected
    definition classes: ScalatraKernel
  9. val _request : DynamicVariable[HttpServletRequest]

    attributes: protected
    definition classes: ScalatraKernel
  10. val _response : DynamicVariable[HttpServletResponse]

    attributes: protected
    definition classes: ScalatraKernel
  11. def acceptHeader : List[String]

  12. def acceptedFormats (accepted: Symbol*) : Boolean

    attributes: protected
  13. def addRoute (verb: String, routeMatchers: Iterable[RouteMatcher], action: ⇒ Any) : Route

    attributes: protected[scalatra]
    definition classes: ScalatraKernel
      deprecated:
    1. Use addRoute(HttpMethod, Iterable[RouteMatcher], =>Any)

  14. def addRoute (method: HttpMethod, routeMatchers: Iterable[RouteMatcher], action: ⇒ Any) : Route

    Prepends a new route for the given HTTP method.

    Prepends a new route for the given HTTP method.

    Can be overriden so that subtraits can use their own logic. Possible examples: - restricting protocols - namespace routes based on class name - raising errors on overlapping entries.

    This is the method invoked by get(), post() etc.

    attributes: protected
    definition classes: ScalatraKernel
      see also:
    1. org.scalatra.ScalatraKernel.removeRoute

  15. def after (routeMatchers: RouteMatcher*)(fun: ⇒ 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.

    definition classes: ScalatraKernelCoreDsl
  16. def afterAll (block: ⇒ Any) : Unit

    attributes: final
    definition classes: CoreDsl
      deprecated:
    1. Use after() { ... }

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

    attributes: final
    definition classes: CoreDsl
      deprecated:
    1. Use after(RouteMatcher*) { ... }

  18. def asInstanceOf [T0] : T0

    This method is used to cast the receiver object to be of type T0.

    This method is used to cast the receiver object to be of type T0.

    Note that the success of a cast at runtime is modulo Scala's erasure semantics. Therefore the expression1.asInstanceOf[String] will throw a ClassCastException at runtime, while the expressionList(1).asInstanceOf[List[String]] will not. In the latter example, because the type argument is erased as part of compilation it is not possible to check whether the contents of the list are of the requested typed.

    returns

    the receiver object.

    attributes: final
    definition classes: Any
  19. def before (routeMatchers: RouteMatcher*)(fun: ⇒ 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.

    definition classes: ScalatraKernelCoreDsl
  20. def beforeAll (block: ⇒ Any) : Unit

    attributes: final
    definition classes: CoreDsl
      deprecated:
    1. Use before() { ... }

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

    attributes: final
    definition classes: CoreDsl
      deprecated:
    1. Use before(RouteMatcher*) { ... }

  22. implicit def booleanBlock2RouteMatcher (block: ⇒ Boolean) : RouteMatcher

    attributes: protected implicit
    definition classes: ScalatraKernel
  23. def clone () : AnyRef

    This method creates and returns a copy of the receiver object.

    This method creates and returns a copy of the receiver object.

    The default implementation of the clone method is platform dependent.

    returns

    a copy of the receiver object.

    attributes: protected[lang]
    definition classes: AnyRef
  24. def contentType : String

    Gets the content type of the current response.

    Gets the content type of the current response.

    definition classes: CoreDsl
  25. def contentTypeInferrer : ContentTypeInferrer

    attributes: protected
    definition classes: ApiFormatsScalatraKernel
  26. def contentType_= (contentType: String) : Unit

    Sets the content type of the current response.

    Sets the content type of the current response.

    definition classes: CoreDsl
  27. def defaultAcceptedFormats : List[Symbol]

  28. val defaultCharacterEncoding : String

    attributes: protected
    definition classes: ScalatraKernel
  29. def defaultFormat : Symbol

  30. def delete (routeMatchers: RouteMatcher*)(action: ⇒ Any) : Route

    definition classes: ScalatraKernelCoreDsl
      see also:
    1. get

  31. var doMethodNotAllowed : (Set[HttpMethod]) ⇒ Any

    attributes: protected
    definition classes: ScalatraKernel
  32. val doNotFound : Action

    attributes: protected abstract
    definition classes: ScalatraKernel
  33. def environment : String

    definition classes: ScalatraKernel
  34. def eq (arg0: AnyRef) : Boolean

    This method is used to test whether the argument (arg0) is a reference to the receiver object (this).

    This method is used to test whether the argument (arg0) is a reference to the receiver object (this).

    The eq method implements an [http://en.wikipedia.org/wiki/Equivalence_relation equivalence relation] on non-null instances of AnyRef: * It is reflexive: for any non-null instance x of type AnyRef, x.eq(x) returns true. * It is symmetric: for any non-null instances x and y of type AnyRef, x.eq(y) returns true if and only if y.eq(x) returns true. * It is transitive: for any non-null instances x, y, and z of type AnyRef if x.eq(y) returns true and y.eq(z) returns true, then x.eq(z) returns true.

    Additionally, the eq method has three other properties. * It is consistent: for any non-null instances x and y of type AnyRef, multiple invocations of x.eq(y) consistently returns true or consistently returns false. * For any non-null instance x of type AnyRef, x.eq(null) and null.eq(x) returns false. * null.eq(null) returns true.

    When overriding the equals or hashCode methods, it is important to ensure that their behavior is consistent with reference equality. Therefore, if two objects are references to each other (o1 eq o2), they should be equal to each other (o1 == o2) and they should hash to the same value (o1.hashCode == o2.hashCode).

    arg0

    the object to compare against this object for reference equality.

    returns

    true if the argument is a reference to the receiver object; false otherwise.

    attributes: final
    definition classes: AnyRef
  35. def equals (arg0: Any) : Boolean

    This method is used to compare the receiver object (this) with the argument object (arg0) for equivalence.

    This method is used to compare the receiver object (this) with the argument object (arg0) for equivalence.

    The default implementations of this method is an [http://en.wikipedia.org/wiki/Equivalence_relation equivalence relation]: * It is reflexive: for any instance x of type Any, x.equals(x) should return true. * It is symmetric: for any instances x and y of type Any, x.equals(y) should return true if and only if y.equals(x) returns true. * It is transitive: for any instances x, y, and z of type AnyRef if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.

    If you override this method, you should verify that your implementation remains an equivalence relation. Additionally, when overriding this method it is often necessary to override hashCode to ensure that objects that are "equal" (o1.equals(o2) returns true) hash to the same scala.Int (o1.hashCode.equals(o2.hashCode)).

    arg0

    the object to compare against this object for equality.

    returns

    true if the receiver object is equivalent to the argument; false otherwise.

    definition classes: AnyRef → Any
  36. 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.

    definition classes: ScalatraKernelCoreDsl
  37. var errorHandler : ErrorHandler

    attributes: protected
    definition classes: ScalatraKernel
  38. def executeRoutes () : Unit

    attributes: protected
    definition classes: ScalatraKernel
  39. def finalize () : Unit

    This method is called by the garbage collector on the receiver object when garbage collection determines that there are no more references to the object.

    This method is called by the garbage collector on the receiver object when garbage collection determines that there are no more references to the object.

    The details of when and if the finalize method are invoked, as well as the interaction between finalizeand non-local returns and exceptions, are all platform dependent.

    attributes: protected[lang]
    definition classes: AnyRef
  40. def format : String

  41. def formatForMimeTypes (mimeTypes: String*) : Option[String]

    attributes: protected
  42. def format_= (formatValue: String) : Unit

  43. def format_= (formatValue: Symbol) : Unit

  44. val formats : ConcurrentMap[String, String]

  45. def get (routeMatchers: RouteMatcher*)(action: ⇒ Any) : Route

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

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

      get("/", request.getRemoteHost == "127.0.0.1") { "Hello localhost!" }
    
    definition classes: ScalatraKernelCoreDsl
  46. def getClass () : java.lang.Class[_]

    Returns a representation that corresponds to the dynamic class of the receiver object.

    Returns a representation that corresponds to the dynamic class of the receiver object.

    The nature of the representation is platform dependent.

    returns

    a representation that corresponds to the dynamic class of the receiver object.

    attributes: final
    definition classes: AnyRef
  47. 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.

    definition classes: ScalatraKernelCoreDsl
  48. def handle (request: HttpServletRequest, response: HttpServletResponse) : Unit

    Accesses the request/response pair, possibly altering them

    Accesses the request/response pair, possibly altering them

    definition classes: ScalatraKernelHandler
  49. def hashCode () : Int

    Returns a hash code value for the object.

    Returns a hash code value for the object.

    The default hashing algorithm is platform dependent.

    Note that it is allowed for two objects to have identical hash codes (o1.hashCode.equals(o2.hashCode)) yet not be equal (o1.equals(o2) returns false). A degenerate implementation could always return 0. However, it is required that if two objects are equal (o1.equals(o2) returns true) that they have identical hash codes (o1.hashCode.equals(o2.hashCode)). Therefore, when overriding this method, be sure to verify that the behavior is consistent with the equals method.

    returns

    the hash code value for the object.

    definition classes: AnyRef → Any
  50. def inferFromFormats : ContentTypeInferrer

    attributes: protected
  51. def initParameter (name: String) : Option[String]

    definition classes: ScalatraKernel
  52. def initialize (config: Config) : Unit

    A hook to initialize the class with some configuration after it has been constructed.

    A hook to initialize the class with some configuration after it has been constructed.

    Not called init because GenericServlet doesn't override it, and then we get into https://lampsvn.epfl.ch/trac/scala/ticket/2497.

    definition classes: ScalatraKernelInitializable
  53. def invoke (matchedRoute: MatchedRoute) : Option[Any]

    attributes: protected
    definition classes: ScalatraKernel
  54. def isDevelopmentMode : Boolean

    definition classes: ScalatraKernel
  55. def isInstanceOf [T0] : Boolean

    This method is used to test whether the dynamic type of the receiver object is T0.

    This method is used to test whether the dynamic type of the receiver object is T0.

    Note that the test result of the test is modulo Scala's erasure semantics. Therefore the expression1.isInstanceOf[String] will return false, while the expression List(1).isInstanceOf[List[String]] will return true. In the latter example, because the type argument is erased as part of compilation it is not possible to check whether the contents of the list are of the requested typed.

    returns

    true if the receiver object is an instance of erasure of type T0; false otherwise.

    attributes: final
    definition classes: Any
  56. def methodNotAllowed (f: (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.

    definition classes: ScalatraKernelCoreDsl
  57. val mimeTypes : ConcurrentMap[String, String]

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

    definition classes: ScalatraKernelCoreDsl
  59. def ne (arg0: AnyRef) : Boolean

    o.ne(arg0) is the same as !(o.eq(arg0)).

    o.ne(arg0) is the same as !(o.eq(arg0)).

    arg0

    the object to compare against this object for reference dis-equality.

    returns

    false if the argument is not a reference to the receiver object; true otherwise.

    attributes: final
    definition classes: AnyRef
  60. def notFound (fun: ⇒ Any) : Unit

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

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

    definition classes: ScalatraKernelCoreDsl
  61. def notify () : Unit

    Wakes up a single thread that is waiting on the receiver object's monitor.

    Wakes up a single thread that is waiting on the receiver object's monitor.

    attributes: final
    definition classes: AnyRef
  62. def notifyAll () : Unit

    Wakes up all threads that are waiting on the receiver object's monitor.

    Wakes up all threads that are waiting on the receiver object's monitor.

    attributes: final
    definition classes: AnyRef
  63. def options (routeMatchers: RouteMatcher*)(action: ⇒ Any) : Route

    definition classes: ScalatraKernelCoreDsl
      see also:
    1. org.scalatra.ScalatraKernel.get

  64. def params : MultiMapHeadView[String, String] with MapWithIndifferentAccess[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.

    definition classes: ScalatraKernelCoreDsl
  65. def pass () : Nothing

    Immediately passes execution to the next matching route.

    Immediately passes execution to the next matching route.

    definition classes: ScalatraKernelCoreDsl
  66. def patch (routeMatchers: RouteMatcher*)(action: ⇒ Any) : Route

    definition classes: ScalatraKernelCoreDsl
      see also:
    1. org.scalatra.ScalatraKernel.get

  67. implicit def pathPatternParser2RouteMatcher (pattern: PathPattern) : RouteMatcher

    Path pattern is decoupled from requests.

    Path pattern is decoupled from requests. This adapts the PathPattern to a RouteMatcher by supplying the request path.

    attributes: protected implicit
    definition classes: ScalatraKernel
  68. def post (routeMatchers: RouteMatcher*)(action: ⇒ Any) : Route

    definition classes: ScalatraKernelCoreDsl
      see also:
    1. get

  69. def put (routeMatchers: RouteMatcher*)(action: ⇒ Any) : Route

    definition classes: ScalatraKernelCoreDsl
      see also:
    1. get

  70. def redirect (uri: String) : Unit

    Sends a redirect response.

    Sends a redirect response.

    definition classes: CoreDsl
  71. implicit def regex2RouteMatcher (regex: Regex) : RouteMatcher

    attributes: protected implicit
    definition classes: ScalatraKernel
  72. def removeRoute (method: String, route: Route) : Unit

    attributes: protected
    definition classes: ScalatraKernel
  73. def removeRoute (method: HttpMethod, route: Route) : Unit

    removes _all_ the actions of a given route for a given HTTP method.

    removes _all_ the actions of a given route for a given HTTP method. If addRoute is overriden this should probably be overriden too.

    attributes: protected
    definition classes: ScalatraKernel
      see also:
    1. org.scalatra.ScalatraKernel.addRoute

  74. def renderPipeline : RenderPipeline

    The render pipeline is a partial function of Any => Any.

    The render pipeline is a partial function of Any => Any. It is called recursively until it returns (). () indicates that the response has been rendered.

    attributes: protected
    definition classes: ScalatraKernel
  75. def renderResponse (actionResult: Any) : Unit

    attributes: protected
    definition classes: ScalatraKernel
  76. def renderResponseBody (actionResult: Any) : Unit

    attributes: protected
    definition classes: ScalatraKernel
  77. implicit def request : HttpServletRequest

    The current request

    The current request

    attributes: implicit
    definition classes: ScalatraKernelCoreDsl
  78. def requestPath : String

    attributes: abstract
    definition classes: ScalatraKernel
  79. implicit def requestWrapper (r: HttpServletRequest) : RichRequest

    attributes: implicit
    definition classes: ServletApiImplicits
  80. implicit def response : HttpServletResponse

    The current response.

    The current response.

    attributes: implicit
    definition classes: ScalatraKernelCoreDsl
  81. lazy val routes : RouteRegistry

    attributes: protected
    definition classes: ScalatraKernel
  82. def runFilters (filters: Traversable[Route]) : Unit

    attributes: protected
    definition classes: ScalatraKernel
  83. def runRoutes (routes: Traversable[Route]) : Stream[Any]

    attributes: protected
    definition classes: ScalatraKernel
  84. def servletContext : ServletContext

    The current servlet context

    The current servlet context

    attributes: abstract
    definition classes: ScalatraKernelCoreDsl
  85. implicit def servletContextWrapper (sc: ServletContext) : RichServletContext

    attributes: implicit
    definition classes: ServletApiImplicits
  86. implicit def session : HttpSession

    The current HTTP session.

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

    attributes: implicit
    definition classes: CoreDsl
  87. def sessionOption : Option[HttpSession]

    The current HTTP session.

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

    definition classes: CoreDsl
  88. implicit def sessionWrapper (s: HttpSession) : RichSession

    attributes: implicit
    definition classes: ServletApiImplicits
  89. def status (code: Int) : Unit

    Sets the status code of the current response.

    Sets the status code of the current response.

    definition classes: CoreDsl
  90. implicit def string2RouteMatcher (path: String) : RouteMatcher

    Pluggable way to convert Strings into RouteMatchers.

    Pluggable way to convert Strings into RouteMatchers. By default, we interpret them the same way Sinatra does.

    attributes: protected implicit
    definition classes: ScalatraKernel
  91. def synchronized [T0] (arg0: T0) : T0

    attributes: final
    definition classes: AnyRef
  92. def toString () : String

    Returns a string representation of the object.

    Returns a string representation of the object.

    The default representation is platform dependent.

    returns

    a string representation of the object.

    definition classes: AnyRef → Any
  93. def wait () : Unit

    attributes: final
    definition classes: AnyRef
  94. def wait (arg0: Long, arg1: Int) : Unit

    attributes: final
    definition classes: AnyRef
  95. def wait (arg0: Long) : Unit

    attributes: final
    definition classes: AnyRef
  96. def withRouteMultiParams [S] (matchedRoute: Option[MatchedRoute])(thunk: ⇒ S) : S

    attributes: protected
    definition classes: ScalatraKernel

Inherited from ScalatraKernel

Inherited from ServletApiImplicits

Inherited from Initializable

Inherited from CoreDsl

Inherited from Handler

Inherited from AnyRef

Inherited from Any