@mashroom/mashroom-http-proxy
Mashroom http proxy service
Last updated a month ago by jkofler .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @mashroom/mashroom-http-proxy 
SYNC missed versions from official npm registry.

Mashroom HTTP proxy

Plugin for Mashroom Server, a Integration Platform for Microfrontends.

Adds a service for forwarding requests to a target URI.

Usage

If node_modules/@mashroom is configured as plugin path just add @mashroom/mashroom-http-proxy as dependency.

After that you can use the service like this:

// @flow

import type {MashroomHttpProxyService} from '@mashroom/mashroom-http-proxy/type-definitions';

export default async (req: ExpressRequest, res: ExpressResponse) => {
    const httpProxyService: MashroomHttpProxyService = req.pluginContext.services.proxy.service;

    const targetURI = 'http://foo.bar/api/test';
    const additionalHeaders = {};
    await httpProxyService.forward(req, res, targetURI, additionalHeaders);
}

You can override the default config in your Mashroom config file like this:

{
    "plugins": {
        "Mashroom Http Proxy Services": {
            "forwardMethods": [
                "GET",
                "POST",
                "PUT",
                "DELETE"
            ],
            "forwardHeaders": [
              "accept",
              "accept-*",
              "range",
              "expires",
              "cache-control",
              "last-modified",
              "content-*",
              "uber-trace-id",
              "uberctx-",
              "b3",
              "x-b3-*",
              "trace*"
            ],
            "rejectUnauthorized": true,
            "poolMaxSockets": 10,
            "socketTimeoutMs": 60000
        }
    }
}
  • forwardMethods: The methods that should be forwarded
  • forwardHeaders: The http headers that should be forwarded. May contain a * as wildcard.
  • rejectUnauthorized: Reject self-signed certificates (Default: true)
  • poolMaxSockets: Max pool size for connections (Default: 10)
  • socketTimeoutMs: Socket timeout, 0 means no timeout (Default: 30000 - 30sec)

Services

MashroomHttpProxyService

The exposed service is accessible through pluginContext.services.proxy.service

Interface:

export interface MashroomHttpProxyService {

    /**
     * Forwards the given request to the targetUri and passes the response from the target to the response object.
     * The Promise will always resolve, you have to check response.statusCode to see if the transfer was successful or not.
     * The Promise will resolve as soon as the whole response was sent to the client.
     */
    forward(req: ExpressRequest, res: ExpressResponse, targetUri: string, additionalHeaders?: HttpHeaders): Promise<void>;
}

Current Tags

  • 1.4.5                                ...           latest (a month ago)

23 Versions

  • 1.4.5                                ...           a month ago
  • 1.4.4                                ...           a month ago
  • 1.4.3                                ...           a month ago
  • 1.4.2                                ...           a month ago
  • 1.4.1                                ...           a month ago
  • 1.4.0                                ...           2 months ago
  • 1.3.2                                ...           3 months ago
  • 1.3.1                                ...           4 months ago
  • 1.3.0                                ...           4 months ago
  • 1.2.3                                ...           5 months ago
  • 1.2.2                                ...           6 months ago
  • 1.2.1                                ...           6 months ago
  • 1.2.0                                ...           7 months ago
  • 1.1.4                                ...           7 months ago
  • 1.1.3                                ...           8 months ago
  • 1.1.2                                ...           8 months ago
  • 1.1.1                                ...           8 months ago
  • 1.1.0                                ...           8 months ago
  • 1.0.94                                ...           9 months ago
  • 1.0.93                                ...           9 months ago
  • 1.0.92                                ...           10 months ago
  • 1.0.91                                ...           10 months ago
  • 1.0.90                                ...           10 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 43
Last Day 0
Last Week 0
Last Month 52
Dependencies (1)
Dev Dependencies (7)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |