Skip to content

srinandan/router

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Microgateway router plugin

Overview

Microgateway exposes proxies deployed on Apigee Edge (that match edgemicro_* proxy name pattern). Microgateway reads the proxyname, basePath and target endpoint from the proxy bundle. Typically proxies have different target endpoints for each environment. In Apigee Edge, the different environments are handled via Target Servers or Route Rules or even some custom code. Since Microgateway does not have access to Target Server or Route Rules, this plugin will help solve this problem.

Scenario

The proxy deployed in Apigee Edge isedgemicro_sample. The basePath is /sample and the target endpoint for dev is http://api.sample1.com, the target endpoint for test is http://api.sample2.com. We'll see how the plugin will help in this situation.

Copy the plugin

Find the MG installation folder. cd <MG_INSTALL>\plugins git clone https://github.com/srinandan/router.git

Enable the plugin

  plugins:
    sequence:
      - oauth
      - router

Configuration Options

  • ttl: Set time to live for cache
  • lookupEndpoint: The endpoint where MG can find target points for a proxy
  • lookupDisabled: To enable or disable the plugin

Sample Configuration

router:
  lookupEndpoint: http://xxxxx/edgemicro-router/endpoint

How does it work?

  • Step 1: The call comes to MG. If the basePath matches a proxy, then proceed to step 2
  • Step 2: check if the proxy name exists in local (in memory cache). if not, proceed to step 3. If yes, step 6.
  • Step 3: invoke the lookupEndpoint url and pass proxy name and revision as parameters. The response contains an environment specific target endpoint.
  • Step 4: Store the endpoint in local cache
  • Step 5: route the request to the new endpoint.
  • Step 6: use the values in the cache to route the request to the target endpoint stored in cache.

Endpoint Lookup Implementation

There are a variety of ways to implement the endpoint lookup. You can use external services like Eureka or Consul. In this example, I have used an Apigee proxy that stores endpoint information in a KVM. The format of the KVM (environment scoped) is proxyname_revision maps to targetendpoint. For ex: edgemicro_sample maps to http://sample1.test.com

The api proxy implementation is included in the repo.

Create KVM

The name of the KVM used by the proxy is microgateway-router. Here is the link to create one: https://docs.apigee.com/management/apis/post/organizations/%7Borg_name%7D/environments/%7Benv_name%7D/keyvaluemaps

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published