1.0.9 • Published 8 years ago

koa-proxy-url v1.0.9

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

koa-proxy-url Build Status Coverage Status

  • Proxy middleware for koa
  • clone from koa-proxy
  • added: option.url support function(http){return url} to free url
  • added:option.customPath
  • added:option.customHost
  • added:this.callBack

Install

$ npm install koa-proxy-url

Usage

Execution order:

  1. customHost
  2. customPath
  3. options.url (if the type of url is function)
app.use(proxy({
    match: /\/proxy/,
    customHost: function (http) {
        let cutomHost = null;
        let host = http.host;
        cutomHost = host == 'test.com' ? 'custom.com' : host;
        return cutomHost;
    },
    customPath: function (http, options) {
        let path = http.path
        if (options.host == 'test.com') {
            path = '/test' + path;
        }
        return path;
    },
    url: function (http) {
        let source = httpQueryParse(http.request).source;
        if (source != undefined) {
            return source
        } else {
            return null;
        }
    },
}));
app.use(function *(next) {
    this.callBack = function (res) {
        console.log(res.statusCode);
        console.log(res.body);
        console.log(res.headers.date);
      }
})

LICENSE

Copyright (c) 2016 popomore. Licensed under the MIT license.

1.0.9

8 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago