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

Use final paths in the reroutes of configuration.json file. #89

Merged

Conversation

juancash
Copy link
Contributor

The idea is the user not have to map all request when use Ocelot like a simple request redirector.

Imagine the following scenario:

  1. An intranet with three web apis.
  2. An internal gateway like unique enter point to internal requests.
  3. An external gateway like unique enter point to external requests.
  4. The web apis (of point 1) can interact via internal gateway.
  5. Our clients and mobiles apps use the api via external gateway.
  6. The external gateway only offers a couple of methods that are mapped in the configuration file. If we need add or quit methods, we edit it´s configuration file.
  7. The apis of intranet can changes frecuently. Every day our developers can implement two o three new controllers per api. We dont want have to edit the internal gateway configuration continously.

The configuration.json for internal gateway could be something like this:

{
      "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
      }
    },
    ...

If we add new controllers to our web apis, we don´t need edit the internal gateway configuration, because the traffic will be redirected without problems.

Thanks.

…on.json file.

Adds a unit test method to test the functionality.
@TomPallister
Copy link
Member

@juancash Looks good thanks for the effort! Could you write an acceptance test for this so we know it works end to end? If you just add it to the RoutingTests.cs file. This shouldn't be too much work as you can just use the methods already in there! Basically copy a test and change it!

@juancash juancash mentioned this pull request Apr 22, 2017
@juancash
Copy link
Contributor Author

@tom Acceptance test added.

@TomPallister
Copy link
Member

@juancash thank you very much! I will merge this now.

@TomPallister TomPallister merged commit 11f5aa0 into ThreeMammals:master Apr 23, 2017
@TomPallister TomPallister added this to Done in Ocelot Aug 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants