The RequestContext object
The REST API framework uses a RequestContext object to represent
information about a single REST API request. The framework uses
RequestContext objects as inputs to the
IRestDispatchPlugin methods. It is possible to pass a
RequestContext object to any API handler method by including a parameter
of type RequestContext on the method.
Usage
The
RequestContext object serves a number of different functions at
runtime. For example, you can use the request RequestContext object to
access the following kinds of information:- The original
HttpServletRequestobject for the request in order to obtain raw request information that might not surface in other ways. - Headers and path parameters by name, in either deserialized (if explicitly listed in
the schema) or raw form.
This type of information is often helpful in writing common infrastructure that multiple API endpoints share.
- Metadata about the request being served such as the
SwaggerOperationobject, path template, or the fully-qualified name of the API. - Other information about the request being handled, such as the negotiated response content type
