tower-rs / tower

async fn(Request) -> Result<Response, Error>
https://docs.rs/tower
MIT License
3.56k stars 281 forks source link

Add "make_infallible_service" #719

Closed DaAitch closed 1 year ago

DaAitch commented 1 year ago

axum::routing::Router and other server impls using tower, often want Infallible services.

This PR brings .make_infallible(err_to_ok_fn) to any Service to fit Service<.., Error = Infallible>. I often need this boilerplate when gluing together a server so I thought opening a PR.

Please let me know, if this is a good idea and if so, I will work on the documentation.