Giter Club home page Giter Club logo

Comments (6)

kevinswiber avatar kevinswiber commented on July 17, 2024

@f1erro and I talked about this yesterday.

  1. Passing null as the second parameter of the next function in ondata_response streams the original data chunk.
  2. The data parameter is actually an object of pluginOptions. To access the chunk, you have to use data.data.
  3. The second parameter of next used in the onend_response function appends to the end of the stream, because the data elements have already been pushed to the stream in ondata_response.

from microgateway-core.

kevinswiber avatar kevinswiber commented on July 17, 2024

To get your example to work, you need to pass an empty buffer like so:

'use strict';

var debug = require('debug')('plugin:response-override');

var emptyBuffer = new Buffer(0);

module.exports.init = function(config, logger, stats) {


  return {

    ondata_response: function(req, res, data, next) {
      debug('***** plugin ondata_response');
      next(null, emptyBuffer);
    },

    onend_response: function(req, res, data, next) {
      debug('***** plugin onend_response');
      next(null, "Hello, World!\n\n");
    }
  };
}

from microgateway-core.

kevinswiber avatar kevinswiber commented on July 17, 2024

@WWitman FYI: Docs are totally borked for plugins, but that's okay for now, because the actual plugin functionality appears to have never worked properly in v2. We're going to look at what we need to do to fix or redesign the broken implementation and will get back to you.

from microgateway-core.

mdobson avatar mdobson commented on July 17, 2024

Yeah. There are definitely a few issues going on here. At least one issue I
have a fix for. I've got a way to pass null instead of an empty buffer to
override a response body.

-Matt

--
Matthew Dobson | apigee https://apigee.com/ | m: +1.734.634.5472 |
twitter @mdobs http://twitter.com/mdobs @apigee
https://twitter.com/apigee | Apigee Community
http://community.apigee.com/
for answers, ideas and support!
http://adapt.apigee.com

On Tue, Oct 11, 2016 at 2:41 PM, Kevin Swiber [email protected]
wrote:

@WWitman https://github.com/WWitman FYI: Docs are totally borked for
plugins, but that's okay for now, because the actual plugin functionality
appears to have never worked properly in v2. We're going to look at what we
need to do to fix or redesign the broken implementation and will get back
to you.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#17 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AA5BsA9Ayu9Io2_Baugv9cI9lEgEunJDks5qy9hAgaJpZM4KTmc3
.

from microgateway-core.

dteirney avatar dteirney commented on July 17, 2024

We're about to implement a plugin. What do we need to know about how to do this if the "documentation is borked".

from microgateway-core.

mdobson avatar mdobson commented on July 17, 2024

See @kevinswiber s work around if you need to do body transformation currently. In a release coming out this week we'll have fixes in EM to actually make the documentation correct again.

from microgateway-core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.