Working With the Request
The AKExchange object manages the data messages as they are passed from module to module. The AKExchange also contains a reference to the AKRequest object. This object can be accessed from any point in the route to get information about the original HTTP request that came from the client. You can access the following information about the request:
- HTTP headers
- HTTP query string parameters
- The body of the HTTP request message
- HTTP form parameters
- Request path and path parameters
- HTTP method
Most commonly, you access the request from the first module in the route. Subsequent modules in the route typically get all their information from the output message of the previous module and not from the originating request.
To get a reference to the AKRequest object, you use the AKExchange class's
getAkulaRequest() method, as the following example shows:
This example does nothing more than pass the input message to the output, but it shows how to instantiate an AKRequest object and iterate over the HTTP headers.