Packages

class RoutingContext extends AnyRef

Represents the context for the handling of a request in Vert.x-Web.

A new instance is created for each HTTP request that is received in the of the router.

The same instance is passed to any matching request or failure handlers during the routing of the request or failure.

The context provides access to the and and allows you to maintain arbitrary data that lives for the lifetime of the context. Contexts are discarded once they have been routed to the handler for the request.

The context also provides access to the io.vertx.scala.ext.web.Session, cookies and body for the request, given the correct handlers in the application.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. RoutingContext
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new RoutingContext(_asJava: AnyRef)

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def acceptableLanguages(): Buffer[LanguageHeader]

    Returns the languages for the current request.

    Returns the languages for the current request. The languages are determined from the Accept-Language header and sorted on quality.

    When 2 or more entries have the same quality then the order used to return the best match is based on the lowest index on the original list. For example if a user has en-US and en-GB with same quality and this order the best match will be en-US because it was declared as first entry by the client. * @return The best matched language for the request

  5. def acceptableLocales(): Buffer[Locale]

    Returns the locales for the current request.

    Returns the locales for the current request. The locales are determined from the accept-languages header and sorted on quality.

    When 2 or more entries have the same quality then the order used to return the best match is based on the lowest index on the original list. For example if a user has en-US and en-GB with same quality and this order the best match will be en-US because it was declared as first entry by the client. * @return the best matched locale for the request

  6. def addBodyEndHandler(handler: Handler[Unit]): Int

    Provides a handler that will be called after the last part of the body is written to the wire.

    Provides a handler that will be called after the last part of the body is written to the wire. The handler is called asynchronously of when the response has been received by the client. This provides a hook allowing you to do more operations once the request has been sent over the wire. Do not use this for resource cleanup as this handler might never get called (e.g. if the connection is reset). * @param handler the handler

    returns

    the id of the handler. This can be used if you later want to remove the handler.

  7. def addCookie(cookie: Cookie): RoutingContext

    Add a cookie.

    Add a cookie. This will be sent back to the client in the response. The context must have first been routed to a io.vertx.scala.ext.web.handler.CookieHandler for this to work. * @param cookie the cookie

    returns

    a reference to this, so the API can be used fluently

  8. def addHeadersEndHandler(handler: Handler[Unit]): Int

    Add a handler that will be called just before headers are written to the response.

    Add a handler that will be called just before headers are written to the response. This gives you a hook where you can write any extra headers before the response has been written when it will be too late. * @param handler the handler

    returns

    the id of the handler. This can be used if you later want to remove the handler.

  9. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  10. def asJava: AnyRef
  11. def clearUser(): Unit

    Clear the current user object in the context.

    Clear the current user object in the context. This usually is used for implementing a log out feature, since the current user is unbounded from the routing context.

  12. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  13. def cookieCount(): Int

    returns

    the number of cookies. The context must have first been routed to a io.vertx.scala.ext.web.handler.CookieHandler for this to work.

  14. def cookies(): Set[Cookie]

    returns

    a set of all the cookies. The context must have first been routed to a io.vertx.scala.ext.web.handler.CookieHandler for this to be populated.

  15. def currentRoute(): Route

    returns

    the current route this context is being routed through.

  16. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  17. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  18. def fail(throwable: Throwable): Unit

    Fail the context with the specified throwable.

    Fail the context with the specified throwable.

    This will cause the router to route the context to any matching failure handlers for the request. If no failure handlers match a default failure response with status code 500 will be sent. * @param throwable a throwable representing the failure

  19. def fail(statusCode: Int): Unit

    Fail the context with the specified status code.

    Fail the context with the specified status code.

    This will cause the router to route the context to any matching failure handlers for the request. If no failure handlers match a default failure response will be sent. * @param statusCode the HTTP status code

  20. def failed(): Boolean

    returns

    true if the context is being routed to failure handlers.

  21. def failure(): Throwable

    If the context is being routed to failure handlers after a failure has been triggered by calling io.vertx.scala.ext.web.RoutingContext#fail then this will return that throwable.

    If the context is being routed to failure handlers after a failure has been triggered by calling io.vertx.scala.ext.web.RoutingContext#fail then this will return that throwable. It can be used by failure handlers to render a response, e.g. create a failure response page. * @return the throwable used when signalling failure

  22. def fileUploads(): Set[FileUpload]

    returns

    a set of fileuploads (if any) for the request. The context must have first been routed to a io.vertx.scala.ext.web.handler.BodyHandler for this to work.

  23. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  24. def get[T](key: String)(implicit arg0: scala.reflect.api.JavaUniverse.TypeTag[T]): T

    Get some data from the context.

    Get some data from the context. The data is available in any handlers that receive the context. * @param key the key for the data

    returns

    the data

  25. def getAcceptableContentType(): Option[String]

    If the route specifies produces matches, e.g.

    If the route specifies produces matches, e.g. produces text/html and text/plain, and the accept header matches one or more of these then this returns the most acceptable match. * @return the most acceptable content type.

  26. def getBody(): Option[Buffer]

    returns

    Get the entire HTTP request body as a Buffer. The context must have first been routed to a io.vertx.scala.ext.web.handler.BodyHandler for this to be populated.

  27. def getBodyAsJson(): Option[JsonObject]

    returns

    Get the entire HTTP request body as a JsonObject. The context must have first been routed to a io.vertx.scala.ext.web.handler.BodyHandler for this to be populated.

  28. def getBodyAsJsonArray(): Option[JsonArray]

    returns

    Get the entire HTTP request body as a JsonArray. The context must have first been routed to a io.vertx.scala.ext.web.handler.BodyHandler for this to be populated.

  29. def getBodyAsString(encoding: String): Option[String]

    Get the entire HTTP request body as a string, assuming the specified encoding.

    Get the entire HTTP request body as a string, assuming the specified encoding. The context must have first been routed to a io.vertx.scala.ext.web.handler.BodyHandler for this to be populated. * @param encoding the encoding, e.g. "UTF-16"

    returns

    the body

  30. def getBodyAsString(): Option[String]

    returns

    the entire HTTP request body as a string, assuming UTF-8 encoding. The context must have first been routed to a io.vertx.scala.ext.web.handler.BodyHandler for this to be populated.

  31. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  32. def getCookie(name: String): Option[Cookie]

    Get the cookie with the specified name.

    Get the cookie with the specified name. The context must have first been routed to a io.vertx.scala.ext.web.handler.CookieHandler for this to work. * @param name the cookie name

    returns

    the cookie

  33. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  34. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  35. def mountPoint(): Option[String]

    returns

    the mount point for this router. It will be null for a top level router. For a sub-router it will be the path at which the subrouter was mounted.

  36. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  37. def next(): Unit

    Tell the router to route this context to the next matching route (if any).

    Tell the router to route this context to the next matching route (if any). This method, if called, does not need to be called during the execution of the handler, it can be called some arbitrary time later, if required.

    If next is not called for a handler then the handler should make sure it ends the response or no response will be sent.

  38. def normalisedPath(): String

    Return the normalised path for the request.

    Return the normalised path for the request.

    The normalised path is where the URI path has been decoded, i.e. any unicode or other illegal URL characters that were encoded in the original URL with % will be returned to their original form. E.g. %20 will revert to a space. Also + reverts to a space in a query.

    The normalised path will also not contain any .. character sequences to prevent resources being accessed outside of the permitted area.

    It's recommended to always use the normalised path as opposed to if accessing server resources requested by a client. * @return the normalised path

  39. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  40. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  41. def parsedHeaders(): ParsedHeaderValues

    The headers:

    The headers:

    • Accept
    • Accept-Charset
    • Accept-Encoding
    • Accept-Language
    • Content-Type

    Parsed into io.vertx.scala.ext.web.ParsedHeaderValue * @return A container with the parsed headers.

  42. def pathParam(name: String): Option[String]

    Gets the value of a single path parameter * @param name the name of parameter as defined in path declaration

    Gets the value of a single path parameter * @param name the name of parameter as defined in path declaration

    returns

    the actual value of the parameter or null if it doesn't exist

  43. def pathParams(): Map[String, String]

    Returns a map of named parameters as defined in path declaration with their actual values * @return the map of named parameters

  44. def preferredLanguage(): LanguageHeader

    Helper to return the user preferred language.

    Helper to return the user preferred language. It is the same action as returning the first element of the acceptable languages. * @return the users preferred locale.

  45. def preferredLocale(): Locale

    Helper to return the user preferred locale.

    Helper to return the user preferred locale. It is the same action as returning the first element of the acceptable locales. * @return the users preferred locale.

  46. def put(key: String, obj: AnyRef): RoutingContext

    Put some arbitrary data in the context.

    Put some arbitrary data in the context. This will be available in any handlers that receive the context. * @param key the key for the data

    obj

    the data

    returns

    a reference to this, so the API can be used fluently

  47. def queryParam(query: String): Option[Buffer[String]]

    Gets the value of a single query parameter * @param query The name of query parameter

    Gets the value of a single query parameter * @param query The name of query parameter

    returns

    The list of all elements inside query parameter

  48. def queryParams(): MultiMap

    Returns a map of all query parameters inside the query string * @return the multimap of query parameters

  49. def remove[T](key: String)(implicit arg0: scala.reflect.api.JavaUniverse.TypeTag[T]): T

    Remove some data from the context.

    Remove some data from the context. The data is available in any handlers that receive the context. * @param key the key for the data

    returns

    the previous data associated with the key

  50. def removeBodyEndHandler(handlerID: Int): Boolean

    Remove a body end handler * @param handlerID the id as returned from io.vertx.scala.ext.web.RoutingContext#addBodyEndHandler(Handler).

    Remove a body end handler * @param handlerID the id as returned from io.vertx.scala.ext.web.RoutingContext#addBodyEndHandler(Handler).

    returns

    true if the handler existed and was removed, false otherwise

  51. def removeCookie(name: String, invalidate: Boolean): Option[Cookie]

    Remove a cookie from the cookie set.

    Remove a cookie from the cookie set. If invalidate is true then it will expire a cookie, notifying a User Agent to remove it from its cookie jar. The context must have first been routed to a io.vertx.scala.ext.web.handler.CookieHandler for this to work. * @param name the name of the cookie

    returns

    the cookie, if it existed, or null

  52. def removeCookie(name: String): Option[Cookie]

    Expire a cookie, notifying a User Agent to remove it from its cookie jar.

    Expire a cookie, notifying a User Agent to remove it from its cookie jar. The context must have first been routed to a io.vertx.scala.ext.web.handler.CookieHandler for this to work. * @param name the name of the cookie

    returns

    the cookie, if it existed, or null

  53. def removeHeadersEndHandler(handlerID: Int): Boolean

    Remove a headers end handler * @param handlerID the id as returned from io.vertx.scala.ext.web.RoutingContext#addHeadersEndHandler(Handler).

    Remove a headers end handler * @param handlerID the id as returned from io.vertx.scala.ext.web.RoutingContext#addHeadersEndHandler(Handler).

    returns

    true if the handler existed and was removed, false otherwise

  54. def request(): HttpServerRequest

    returns

    the HTTP request object

  55. def reroute(method: HttpMethod, path: String): Unit

    Restarts the current router with a new method and path.

    Restarts the current router with a new method and path. All path parameters are then parsed and available on the params list. * @param method the new http request

    path

    the new http path.

  56. def reroute(path: String): Unit

    Restarts the current router with a new path and reusing the original method.

    Restarts the current router with a new path and reusing the original method. All path parameters are then parsed and available on the params list. * @param path the new http path.

  57. def response(): HttpServerResponse

    returns

    the HTTP response object

  58. def session(): Option[Session]

    Get the session.

    Get the session. The context must have first been routed to a io.vertx.scala.ext.web.handler.SessionHandler for this to be populated. Sessions live for a browser session, and are maintained by session cookies. * @return the session.

  59. def setAcceptableContentType(contentType: Option[String]): Unit

    Set the acceptable content type.

    Set the acceptable content type. Used by * @param contentType the content type

  60. def setBody(body: Buffer): Unit

    Set the body.

    Set the body. Used by the io.vertx.scala.ext.web.handler.BodyHandler. You will not normally call this method. * @param body the body

  61. def setSession(session: Session): Unit

    Set the session.

    Set the session. Used by the io.vertx.scala.ext.web.handler.SessionHandler. You will not normally call this method. * @param session the session

  62. def setUser(user: User): Unit

    Set the user.

    Set the user. Usually used by auth handlers to inject a User. You will not normally call this method. * @param user the user

  63. def statusCode(): Int

    If the context is being routed to failure handlers after a failure has been triggered by calling io.vertx.scala.ext.web.RoutingContext#fail then this will return that status code.

    If the context is being routed to failure handlers after a failure has been triggered by calling io.vertx.scala.ext.web.RoutingContext#fail then this will return that status code. It can be used by failure handlers to render a response, e.g. create a failure response page.

    When the status code has not been set yet (it is undefined) its value will be -1. * @return the status code used when signalling failure

  64. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  65. def toString(): String
    Definition Classes
    AnyRef → Any
  66. def user(): Option[User]

    Get the authenticated user (if any).

    Get the authenticated user (if any). This will usually be injected by an auth handler if authentication if successful. * @return the user, or null if the current user is not authenticated.

  67. def vertx(): Vertx

    returns

    the Vert.x instance associated to the initiating Router for this context

  68. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  69. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  70. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped