tower/tower-service
Daniél Kerkmann 89ac74f320
feat: Make new functions const when possible (#760)
* feat: Make new functions const when possible

The main reason was to allow to initialize the RateLimitLayer in a const context.
So why not making ever new function const (wherever it's possible). :P

* Change the assert to use an MSRV-compatible function.

---------

Co-authored-by: Toby Lawrence <tobz@users.noreply.github.com>
2024-07-20 13:18:29 -04:00
..
2023-04-11 18:55:52 +02:00
2019-04-26 21:31:25 -07:00

Tower Service

The foundational Service trait that Tower is based on.

Crates.io Documentation Documentation (master) MIT licensed Build Status Discord chat

Overview

The Service trait provides the foundation upon which Tower is built. It is a simple, but powerful trait. At its heart, Service is just an asynchronous function of request to response.

async fn(Request) -> Result<Response, Error>

Implementations of Service take a request, the type of which varies per protocol, and returns a future representing the eventual completion or failure of the response.

Services are used to represent both clients and servers. An instance of Service is used through a client; a server implements Service.

By using standardizing the interface, middleware can be created. Middleware implement Service by passing the request to another Service. The middleware may take actions such as modify the request.

License

This project is licensed under the MIT license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Tower by you, shall be licensed as MIT, without any additional terms or conditions.