# Middlewares

Sometimes, you may need to perform some tasks, such as altering the traffic that is captured by Hypertest. This can be done programmatically via "Middlewares" which are in simple terms, functions that a user can write in order to implement a custom functionality.

# Using middlewares

middlewares

A middleware section contains the following parts:

  • Middleware Name
  • Description
  • Sample data contains test data on which the middleware provided would be run, in order to verify its correctness.
  • Input globals is the list of variables globally available in the middleware body
  • Code contains the actual middleware code, it is here that the middleware is written

TIP

After writing your middleware always use the check output function to verify the middleware.

# Middleware Types

Following is a detailed explanation of all the middlewares that Hypertest provides:

  • REQUEST_LOGGER_V1: Changes request parameter in newly logged requests based on the parameters provided to it.

  • SESSION_DIFFERENTIATOR_V1: Used when the session differentiator value needs to figured out programmatically. For example, sorting incoming requests into groups; those that have a specific key in header are grouped together, those that have same ip are grouped together and so on.

  • REQUEST_MODIFIER_V1: Alters response by modifying request parameters.

  • OVERRIDE_SESSION_REQUESTS_V1: Override headers, query, body for subsequent requests in a session.

  • POST_RESPONSE_SESSION_VARIABLES_V1: Updates the session variables for a particular request.