trait
Handler extends AnyRef
Abstract Value Members
-
abstract
def
handle(req: HttpServletRequest, res: HttpServletResponse): Unit
Concrete Value Members
-
final
def
!=(arg0: AnyRef): Boolean
-
final
def
!=(arg0: Any): Boolean
-
final
def
##(): Int
-
final
def
==(arg0: AnyRef): Boolean
-
final
def
==(arg0: Any): Boolean
-
final
def
asInstanceOf[T0]: T0
-
def
clone(): AnyRef
-
final
def
eq(arg0: AnyRef): Boolean
-
def
equals(arg0: Any): Boolean
-
def
finalize(): Unit
-
final
def
getClass(): Class[_]
-
def
hashCode(): Int
-
final
def
isInstanceOf[T0]: Boolean
-
final
def
ne(arg0: AnyRef): Boolean
-
final
def
notify(): Unit
-
final
def
notifyAll(): Unit
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
-
def
toString(): String
-
final
def
wait(): Unit
-
final
def
wait(arg0: Long, arg1: Int): Unit
-
final
def
wait(arg0: Long): Unit
Inherited from AnyRef
Inherited from Any
An
Handler
is the Scalatra abstraction for an object that operates on a request/response pair.Such an object can, for example, look at the request headers and deny access to a resource, or transform request parameters and later call the
handle()
method of the class in which it had been mixed in, or anything else.Handler
s are somewhat similar to servlet Filters, but since they are traits that can be mixed in they also provide a form of code reuse. For example, org.scalatra.FlashMapSupport and org.scalatra.CookieSupport are twoHandler
s that provide utility methods to access the request/response pair.org.scalatra.ScalatraKernel (and thus all the Scalatra applications) is a
Handler
too: itshandle()
method works as a dispatcher to the possible routes. Thanks to trait-stacking, any same-named method that is mixed in in your Scalatra servlet or filter gets called together with the dispatching action, providing the mixed in functionalities to all the invoked actions.Handler
instances are usually shared among threads thus any state change produced in this method (outsid of side effects on the arguments tohandle(req,res)
should be wrapped in a scala.util.DynamicVariable , which is thread-local.