Skip to main content

Overview

alt text

In JetProxy, middleware is a powerful tool used to modify or adjust requests before they are forwarded to your services, or to modify responses before they are sent back to the clients.

JetProxy offers several types of middleware that can be used to customize the behavior of your requests. For example, some middleware can handle authentication, or even manage caching behavior. Middleware provides a way to add additional layers of control and customization to ensure that requests and responses meet your application's needs.

Multiple middleware that use the same protocol can be combined into a chain, allowing for flexible and powerful configurations to handle a wide variety of scenarios.

Configuring Examples

proxies:
- path: /products
service: productApi
middleware:
auth: 'basicAuth:roleA' # Add basic Auth with Role
rule: "(Header('Content-Type', 'application/json') && HeaderPrefix('User-Agent', 'Mozilla')) || HeaderRegex('X-Custom-Header', '^[a-zA-Z0-9]{10}$')" # Rule Mathcing
circuitBreaker:
enabled: true
failureThreshold: 50 # 50% failure rate threshold
slowCallThreshold: 50 # 50% slow call rate threshold
slowCallDuration: 2000 # 2 seconds threshold for slow calls
openStateDuration: 10 # 10-second wait in open state
waitDurationInOpenState: 10000 # 10-second wait in open state
permittedNumberOfCallsInHalfOpenState: 3 # 3 calls in half-open state
minimumNumberOfCalls: 5 # Minimum of 5 calls before evaluating
ttl: 1000 # Enabled HTTP Cache

Available HTTP Middlewares

MiddlewareDescriptionLink
BasicAuthHandles basic authentication.Documentation
ForwardAuthForwards authentication to an external service.Documentation
JWT AuthValidates and processes JSON Web Tokens (JWT).Documentation
RulesDefines routing and matching rules.Documentation
HeadersManages request and response headers.Documentation
CacheConfigures caching for responses.Documentation
Circuit BreakerImplements circuit breaker logic for fault tolerance.Documentation
CORS HeadersHandles Cross-Origin Resource Sharing (CORS) headers.Documentation
Rate LimiterLimits the rate of incoming requests.Documentation
Mirroring RequestForwards a copy of the incoming request to another service for testing or shadowing.Documentation
Rest To GrpcConverts incoming REST requests to gRPC protocol calls.Documentation
Idempotency RequestEnsures safe retries by returning the same response for repeated requests with the same key.Documentation