Is it possible, in Edge micro, to configure a plugin to "short circuit" the proxy behavior?

Basically I want to configure Edge Micro to dispense a token, directly. In that special case it would not proxy to a remote service, but instead would respond directly.

In other words, I'd have an app send a request like this:

POST https://edge-micro-location/token -d 'payload-goes-here'

... and Edge micro would receive that and do... something... then respond with a token. Is it possible to build a plugin that does this? If so, how?

Solved Solved
0 1 156
1 ACCEPTED SOLUTION

Not applicable

Hi Dino,

Yes, you should be able to simply write a plugin that has middleware that writes to the response object as appropriate (and doesn't call next()). In other words, something like this:

var middleware = function (req, res, next) {
  // if not token request, skip
  if (!tokenRequest) return next()

  // if token request...
  res.statusCode = 200
  res.end("my response")
}

Hope that helps!

Scott

View solution in original post

1 REPLY 1

Not applicable

Hi Dino,

Yes, you should be able to simply write a plugin that has middleware that writes to the response object as appropriate (and doesn't call next()). In other words, something like this:

var middleware = function (req, res, next) {
  // if not token request, skip
  if (!tokenRequest) return next()

  // if token request...
  res.statusCode = 200
  res.end("my response")
}

Hope that helps!

Scott