dotnet / dotnet/yarp

Missing DI possibilities in using HttpTransformer

Open
#2,027 15 comments 7 reactions 0 assignees View on GitHub
Type: Feedback
Dominant language
C#
Stars
9.6k
Forks
933
Avg merge
12d 18h
Merged PRs (30d)
2

Description

### Some details

**How many backends are in your application?**

- [ ] 1-2
- [ ] 3-5
- [ ] 6-10
- [x] 10+

**How do you host your application?**

- [ ] Kubernetes
- [x] Azure App Service
- [ ] Azure VMs
- [ ] Other Cloud Provider (please include details below)
- [ ] Other Hosting model (please include details below)

### What did you think of YARP?

We are using the HttpForwarder functionality of YARP to dynamically reroute incoming requests to another server, and it seems to work really well. However, we are missing a functionality to use DI in the HttpTransformer class. Because we always have to pass an instance of a HttpTransformer to the MapForwarder method, there is no way to use scoped services within the HttpTransformer, other than passing the ServiceProvider itself to the HttpTransformer and manually creating a scope and resolving services in the HttpTransformer. We would really like it if we were able to register a scoped HttpTransformer to the ServiceCollection and have the HttpForwarder resolve the HttpTransformer from the ServiceCollection, so we can use scoped services in the HttpTransformer constructor

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.