Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using transforms #31

Open
q-bertsuit opened this issue Mar 13, 2024 · 2 comments
Open

Using transforms #31

q-bertsuit opened this issue Mar 13, 2024 · 2 comments

Comments

@q-bertsuit
Copy link

q-bertsuit commented Mar 13, 2024

If I have an app behind my YARP Reverse Proxy that exposes this endpoint

http://localhost:5001/MyController/MyEndpoint

And I want the user to be able to reach this via my reverse proxy like this (using a dash):

http://localhost:5000/api/v1/my-controller/MyEndpoint

I could add a transform to my YARP config like so:

"ReverseProxy": {
    "Routes": [
      {
        "RouteId": "my-service",
        "ClusterId": "my-service",
        "Match": {
          "Path": "/api/v1/my-controller/{**catch-all}"
        },
        "Transforms": [
          {
            "PathPattern": "/mycontroller/{**catch-all}"
          }
        ]
      }
}

A problem arises when I try to define my swaggers. I can add a PrefixPath like "/api/v1/my-controller/", but the swagger documentation will then expose the endpoint as /api/v1/my-controller/mycontroller/myendpoint

Is there a way to handle transforms like this?

@andreytreyt
Copy link
Owner

@q-bertsuit Hi! Yes, you're right. I recommend to try to change configuration of path patterns. Maybe configuration of a few routes and clusters helps you.

@fruhnow
Copy link

fruhnow commented Jun 26, 2024

I am running into the same problem. I set up Yarp to proxy requests to my services and used this library to unify my swagger definitions. When visiting the new unified swagger instance it uses the initial Paths of the services it combines behind the Yarp instance instead of the new Yarp Paths which lead to no success. I tried to implement a TransformFactory but couldn't find a way to manipulate the request urls. Are there any hints u can give to resolve this issue?

Kind Regards and thanks for your awesome work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants