Skip to main content

Module middleware

Module middleware 

Source
Expand description

§HTTP 中间件模块

提供常用的 HTTP 中间件实现。

§中间件列表

  • CORS - 跨域资源共享配置
  • Compression - 响应压缩
  • Request ID - 请求追踪 ID
  • Tracing - 请求追踪与日志

§重新导出

本模块还重新导出 tower-http 的常用中间件:

  • CatchPanicLayer
  • NormalizePathLayer
  • MakeRequestUuid
  • SetRequestHeaderLayer
  • SetResponseHeaderLayer
  • TimeoutLayer

Structs§

CatchPanicLayer
重新导出 tower-http 的常用中间件 Layer that applies the CatchPanic middleware that catches panics and converts them into 500 Internal Server responses.
Compression
压缩中间件层
CompressionBuilder
压缩中间件构建器
CompressionConfig
压缩配置
CorsConfig
CORS 配置结构体
CorsLayer
Layer that applies the Cors middleware which adds headers for CORS.
MakeRequestUuid
重新导出 tower-http 的常用中间件 A MakeRequestId that generates UUIDs.
NormalizePathConfig
路径归一化配置
NormalizePathLayer
重新导出 tower-http 的常用中间件 Layer that applies NormalizePath which normalizes paths.
RequestIdLayer
请求 ID 中间件层
SetRequestHeaderLayer
重新导出 tower-http 的常用中间件 Layer that applies SetRequestHeader which adds a request header.
SetResponseHeaderLayer
重新导出 tower-http 的常用中间件 Layer that applies SetResponseHeader which adds a response header.
TimeoutBuilder
超时中间件构建器
TimeoutLayer
重新导出 tower-http 的常用中间件 Layer that applies the Timeout middleware which apply a timeout to requests.
TracingLayer
追踪中间件层

Enums§

CompressionAlgorithm
压缩算法类型

Functions§

cors_permissive
创建允许所有请求的 CORS 配置
cors_strict
创建严格模式的 CORS 配置