Tower Middleware Compatibility
Salvo provides compatibility support for the Tower ecosystem through the tower-compat feature. For specific APIs, please refer to the documentation.
Core Concepts of Tower
Tower is a service abstraction library primarily based on two core traits:
Service Trait
The Service trait is responsible for handling requests and returning responses, similar to Salvo's handlers.
Layer Trait
The Layer trait is used to wrap services and add additional functionality, similar to Salvo's middleware.
Salvo Compatibility Support
Salvo provides two key traits to achieve compatibility with the Tower ecosystem:
- TowerLayerCompat: Converts Tower's
Layerinto Salvo'sHandler, allowing it to be used as a Hoop (middleware). - TowerServiceCompat: Converts Tower's
Serviceinto Salvo'sHandler.
Usage Example:
Example Code