Comments (6)
@danny-waite I had a look at that pathprefix and tbh didn't really get it :( I can be a bit stupid. Could you explain to me exactly what you want to do?
I'm thinking rather than defining all your incoming requests with the API gateway you want to have some kind of easy to define convention that just works for most / all of your incoming requests?
Ocelot wasn't designed with that in mind initially thought it would be a good feature.
If I was you I would go with traefik! Seems to be quite decent. Kong and Tyk look good too.
from ocelot.
In my case I have 3 api and I only want redirect the traffic via Ocelot, I thinked in the following configuration:
{
"UpstreamPathTemplate": "/api/api1/{urlPath}",
"UpstreamHttpMethod": "Get",
"DownstreamPathTemplate": "/api/{urlPath}",
"DownstreamScheme": "http",
"DownstreamHost": "localhost",
"DownstreamPort": 5001,
"QoSOptions": {
"ExceptionsAllowedBeforeBreaking": 3,
"DurationOfBreak": 10,
"TimeoutValue": 10000
}
},
{
"UpstreamPathTemplate": "/api/api2/{urlPath}",
"UpstreamHttpMethod": "Get",
"DownstreamPathTemplate": "/api/{urlPath}",
"DownstreamScheme": "http",
"DownstreamHost": "localhost",
"DownstreamPort": 5002,
"QoSOptions": {
"ExceptionsAllowedBeforeBreaking": 3,
"DurationOfBreak": 10,
"TimeoutValue": 10000
}
},
{
"UpstreamPathTemplate": "/api/api3/{urlPath}",
"UpstreamHttpMethod": "Get",
"DownstreamPathTemplate": "/api/{urlPath}",
"DownstreamScheme": "http",
"DownstreamHost": "localhost",
"DownstreamPort": 5003,
"QoSOptions": {
"ExceptionsAllowedBeforeBreaking": 3,
"DurationOfBreak": 10,
"TimeoutValue": 10000
}
},
The requests to:
/api/api1 is redirected to port 5001
/api/api2 is redirected to port 5002
/api/api3 is redirected to port 5003
When I do a request to /api/api1/values works fine but with /api/api1/values/5 not works.
In the last case my api receive the request /api/values instead of /api/values/5.
Seems that the problem is with the parameters or slash character.
Maybe the problem is in the class UrlPathPlaceholderNameAndValueFinder.cs like you comment in post #74
It´s possible develop this? The idea it´s not to have to edit de configuration.json of our gateway every time we add new controllers to api1, api2 and api3. In this way, we have only edit the configuration.json when we need add a new api.
Thanks.
from ocelot.
I created a fork of your project and created a branch to add this functionality. The changes are only a couple of lines. I don´t know if you want add this to your project. In affirmative case, say me what I must to do, because it´s my first time on github.
Thanks.
from ocelot.
@juancash looks good, i left a comment on the PR if you could take a look. Thanks very much for your efforts!!
from ocelot.
@tom Acceptance test added to the PR #89.
Thanks to you for this great project.
from ocelot.
@juancash thank you once again, I really liked the way you made this change! Very simple 👍
from ocelot.
Related Issues (20)
- Use Polly v8 syntax HOT 4
- Authentication docs could do with a note around .NET 8 changes HOT 1
- The Getting Started document could be updated for .NET 8 HOT 4
- Use Ocelot / Identity Server4 JwtBearerEvents.OnAuthenticationFailed addHeaders not work HOT 9
- Apply rate limiting globally HOT 5
- Download file API causes Gateway memory to rise by fileSize HOT 15
- UpstreamHost not working HOT 8
- Routes containing attribute "UpstreamHost " cannot be found HOT 1
- Issue with Aggregator in Ocelot: Requires At Least Two Routes to Execute HOT 11
- 在使用异步流返回时,并不是实时刷新逐条返回结果,而是一次返回结果 HOT 10
- How to Authorize with nested JWT claim generated from Keycloak
- Access to the path '/app/ocelot.json' is denied HOT 1
- Ocelot is missing NuGet package README file HOT 3
- Kubernetes provider should identify different ports HOT 14
- FTP is raising Exception of Timeout but working in FileZilla and WinSCP HOT 3
- UnableToFindDownstreamRouteError, Failed to match Route configuration for upstream path: /, verb: GET HOT 8
- Rate Limiting issues in Ocelot HOT 6
- Ocelot Downstream Request Timeout HOT 5
- How to find servicename on PreAuthorizationMiddleware HOT 1
- Proposal to add ExtraProps to the configuration HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ocelot.