1.0.9 • Published 10 years ago

koa-proxy-url v1.0.9

Weekly downloads
1
License
MIT
Repository
github
Last release
10 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

10 years ago

1.0.8

10 years ago

1.0.7

10 years ago

1.0.6

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago