Membrane API Gateway harnesses a configurable series of plugins to direct the HTTP message flow. Each plugin can inspect HTTP headers, read and amend message content, or invert the message flow in response to processing directives or errors.
The message exchange is initiated by the HTTP Server Handler that receives the request and spawns an Exchange object. This object flows through a pipeline of plugins, carrying all information about the request and response. Plugins have the capacity to continue processing or to redirect the flow. Plugins must implement the handle methods from the interface Interceptor . An abort handler, which is invoked if a subsequent plugin throws an exception ensures that the plugin can safely free resources of the failed exchange.
Within Membrane, plugins are instantiated once per flow, within thread-safe pipelines. During the exchange, plugins can maintain state and use it at multiple points in the flow. At the end of the exchange, once the response is delivered to the client, the plugins are destroyed.