Skip to main content

Module layer

Module layer 

Available on crate features http and std only.
Expand description

Http Layers provided by Rama.

A Layer, as defined in rama_core::Service, is a middleware that can modify the request and/or response of a Services. It is also capable of branching between two or more Services.

Examples:

  • auth: A layer that can be used to authenticate requests, branching in case the request is not authenticated (read: rejected).
  • cors: A layer that can be used to add CORS headers to the response.

Most layers are implemented as a Service, and then wrapped in a Layer. This is done to allow the layer to be used as a service, and to allow it to be composed with other layers.

Modules§

auth
Authorization related middleware.
body_limit
Apply a limit to the request body.
catch_panic
Convert panics into responses.
classify
Tools for classifying responses as either success or failure.
collect_body
Collect the http Body
compressioncompression
Middleware that compresses response bodies.
cors
Middleware which adds headers for CORS.
csrf
Modern protection against cross-site request forgery (CSRF) attacks.
decompressioncompression
Middleware that decompresses request and response bodies.
dns
Layers in function of DNS.
dpi_proxy_credential
Middleware that extracts credentials for an egress proxy found in the Proxy-Authorization header of a passthrough request.
error_handling
Middleware to turn Service errors into Responses.
follow_redirect
Middleware for following redirections.
forwarded
Middleware to support the reading and writing of Forwarded headers.
har
HAR support, mostly to export using a recorder (e.g. export to files on the local FS).
header_config
Extract a header config from a request or response and insert it into Extensions.
header_from_str_config
Extract a header config from a request or response and insert it into Extensions.
header_option_value
Similar to super::header_config::HeaderConfigLayer, but storing the Default value of type T in case the header with the given HeaderName is present and has a bool-like value.
html_rewritehtml
Middleware that rewrites text/html response bodies on the fly, using rama’s streaming HTML rewriter (crate::protocols::html::rewrite).
into_response
json_capture
Streaming request or response body utilities for capturing selected JSON values while forwarding the body unchanged.
json_rewrite
Middleware that rewrites JSON request or response bodies on the fly, using rama’s streaming JSON rewriter (rama_json::rewrite).
map_request_body
Apply a transformation to the request body.
map_response_body
Apply a transformation to the response body.
match_redirect
Middleware to redirect a request using dynamic Uri derived from the input request or a static one.
normalize_path
Middleware that normalizes paths.
opentelemetryopentelemetry
Http OpenTelemetry Layer Support for Rama.
propagate_headers
Propagate a header from the request to the response.
proxy_auth
Middleware that validates if a request has the appropriate Proxy Authorisation.
remove_header
Middleware for removing headers from requests and responses.
request_id
Set and propagate request ids.
required_header
Middleware for setting required headers on requests and responses, if they are missing.
retry
Middleware for retrying “failed” requests.
rewrite_uri
Middleware to rewrite the Uri of a request.
sensitive_headers
Middlewares that mark headers as sensitive.
set_header
Middleware for setting headers on requests and responses.
set_status
Middleware to override status codes.
timeout
Middleware that applies a timeout to requests.
trace
Middleware that adds high level tracing to a Service.
traffic_writer
Middleware to write Http traffic in std format.
upgrade
middleware to handle branching into http upgrade services
validate_request
Middleware that validates requests.
version_adapter