@makeflow/gateway
Advanced tools
Comparing version 0.1.3 to 0.1.4
import { Context, Next } from 'koa'; | ||
import { Dict } from 'tslang'; | ||
export declare type GatewayTargetMatchFunction = (context: Context) => string | undefined; | ||
export interface IGatewayTargetDescriptor { | ||
type: string; | ||
match?: string | RegExp | { | ||
match?: string | RegExp | GatewayTargetMatchFunction | { | ||
path?: string | RegExp; | ||
headers?: Dict<string | RegExp | boolean>; | ||
test?(context: Context): boolean; | ||
}; | ||
@@ -10,0 +10,0 @@ session?: boolean; |
@@ -23,3 +23,6 @@ "use strict"; | ||
} | ||
let { path: pathPattern, headers: headerPatternDict, test } = match; | ||
if (typeof match === 'function') { | ||
return match(context); | ||
} | ||
let { path: pathPattern, headers: headerPatternDict } = match; | ||
let base = ''; | ||
@@ -36,5 +39,2 @@ if (pathPattern) { | ||
} | ||
if (test && !test(context)) { | ||
return undefined; | ||
} | ||
return base; | ||
@@ -41,0 +41,0 @@ } |
{ | ||
"name": "@makeflow/gateway", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"repository": { | ||
@@ -5,0 +5,0 @@ "type": "git", |
@@ -10,2 +10,6 @@ import {Context, Next} from 'koa'; | ||
export type GatewayTargetMatchFunction = ( | ||
context: Context, | ||
) => string | undefined; | ||
export interface IGatewayTargetDescriptor { | ||
@@ -16,6 +20,6 @@ type: string; | ||
| RegExp | ||
| GatewayTargetMatchFunction | ||
| { | ||
path?: string | RegExp; | ||
headers?: Dict<string | RegExp | boolean>; | ||
test?(context: Context): boolean; | ||
}; | ||
@@ -47,4 +51,8 @@ session?: boolean; | ||
let {path: pathPattern, headers: headerPatternDict, test} = match; | ||
if (typeof match === 'function') { | ||
return match(context); | ||
} | ||
let {path: pathPattern, headers: headerPatternDict} = match; | ||
let base: string | undefined = ''; | ||
@@ -67,6 +75,2 @@ | ||
if (test && !test(context)) { | ||
return undefined; | ||
} | ||
return base; | ||
@@ -73,0 +77,0 @@ } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
43156
834