add catch all failure to prevent analytics plugin from crashing microgateway
1 file changed
tree: f264a394aadfa70f0be71cdf267e25769f1e9419
  1. accesscontrol/
  2. accumulate-request/
  3. accumulate-response/
  4. analytics/
  5. bin/
  6. cloud-foundry-route-service/
  7. config/
  8. eurekaclient/
  9. header-uppercase/
  10. healthcheck/
  11. json2xml/
  12. oauth/
  13. quota/
  14. quota-memory/
  15. spikearrest/
  16. test/
  17. test-helper/
  18. test-one/
  19. test-two/
  20. transform-uppercase/
  21. .gitignore
  22. .travis.yml
  23. index.js
  24. LICENSE
  25. package.json
  26. README.md
README.md

#Plugins

Build Status Build Status

##Overview This repo contains plugins for the microgateway-core project.

These plugins can be loaded into the microgateway calling the load plugin method

##Building a plugin must contain an init method which returns an object literal with all of the handlers

{
  init:function(config,logger,stats){
    return {
    onrequest:function(req,res,[options],next){
    },
    ...
    }
  }
}

init method must return an object with handler methods for each event

the available handlers are

  • on_request
  • ondata_request
  • onend_request
  • on_response
  • ondata_response
  • onend_response
  • onclose_response
  • onerror_response

the handler signature will look like

function(sourceRequest,sourceResponse,[options],next){}
  • sourceRequest: the request from the northbound server

  • sourceResponse the response to the northbound server

  • options: are the full scope of fields you might need to operate on.

    	const options = {
        targetResponse: options.targetResponse,
        targetRequest: options.targetRequest,
        sourceRequest: options.sourceRequest,
        sourceResponse: options.sourceResponse,
        data: data
      };
    
  • you must call next with an error if you errored out like

next([err])