@higress/wasm-assemblyscript
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -64,3 +64,3 @@ import { Log } from "./log_wrapper"; | ||
hasCustomConfig: boolean; | ||
ruleMatcher!: RuleMatcher<PluginConfig>; | ||
ruleMatcher: RuleMatcher<PluginConfig>; | ||
parseConfig: ParseConfigFunc<PluginConfig> | null; | ||
@@ -76,3 +76,3 @@ onHttpRequestHeaders: OnHttpHeadersFunc<PluginConfig> | null; | ||
this.pluginName = pluginName; | ||
Logger = new Log(this.pluginName); | ||
Logger = new Log(pluginName); | ||
this.hasCustomConfig = true; | ||
@@ -79,0 +79,0 @@ this.onHttpRequestHeaders = null; |
@@ -8,6 +8,5 @@ import { | ||
export function getRequestScheme(): string { | ||
let scheme: string | null = stream_context.headers.request.get(":scheme"); | ||
if (scheme == null) { | ||
let scheme: string = stream_context.headers.request.get(":scheme"); | ||
if (scheme == "") { | ||
log(LogLevelValues.error, "Parse request scheme failed"); | ||
return ""; | ||
} | ||
@@ -18,6 +17,5 @@ return scheme; | ||
export function getRequestHost(): string { | ||
let host: string | null = stream_context.headers.request.get(":authority"); | ||
if (host == null) { | ||
let host: string = stream_context.headers.request.get(":authority"); | ||
if (host == "") { | ||
log(LogLevelValues.error, "Parse request host failed"); | ||
return ""; | ||
} | ||
@@ -28,6 +26,5 @@ return host; | ||
export function getRequestPath(): string { | ||
let path: string | null = stream_context.headers.request.get(":path"); | ||
if (path == null) { | ||
let path: string = stream_context.headers.request.get(":path"); | ||
if (path == "") { | ||
log(LogLevelValues.error, "Parse request path failed"); | ||
return ""; | ||
} | ||
@@ -38,6 +35,5 @@ return path; | ||
export function getRequestMethod(): string { | ||
let method: string | null = stream_context.headers.request.get(":method"); | ||
if (method == null) { | ||
let method: string = stream_context.headers.request.get(":method"); | ||
if (method == "") { | ||
log(LogLevelValues.error, "Parse request method failed"); | ||
return ""; | ||
} | ||
@@ -48,9 +44,9 @@ return method; | ||
export function isBinaryRequestBody(): boolean { | ||
let contentType: string | null = stream_context.headers.request.get("content-type"); | ||
if (contentType != null && (contentType.includes("octet-stream") || contentType.includes("grpc"))) { | ||
let contentType: string = stream_context.headers.request.get("content-type"); | ||
if (contentType != "" && (contentType.includes("octet-stream") || contentType.includes("grpc"))) { | ||
return true; | ||
} | ||
let encoding: string | null = stream_context.headers.request.get("content-encoding"); | ||
if (encoding != null && encoding != "") { | ||
let encoding: string = stream_context.headers.request.get("content-encoding"); | ||
if (encoding != "") { | ||
return true; | ||
@@ -63,9 +59,9 @@ } | ||
export function isBinaryResponseBody(): boolean { | ||
let contentType: string | null = stream_context.headers.response.get("content-type"); | ||
if (contentType != null && (contentType.includes("octet-stream") || contentType.includes("grpc"))) { | ||
let contentType: string = stream_context.headers.response.get("content-type"); | ||
if (contentType != "" && (contentType.includes("octet-stream") || contentType.includes("grpc"))) { | ||
return true; | ||
} | ||
let encoding: string | null = stream_context.headers.response.get("content-encoding"); | ||
if (encoding != null && encoding != "") { | ||
let encoding: string = stream_context.headers.response.get("content-encoding"); | ||
if (encoding != "") { | ||
return true; | ||
@@ -72,0 +68,0 @@ } |
@@ -77,3 +77,2 @@ import { getRequestHost } from "./request_wrapper"; | ||
const routeName = String.UTF8.decode(result.returnValue); | ||
for (let i = 0; i < this.ruleConfig.length; i++) { | ||
@@ -83,2 +82,3 @@ const rule = this.ruleConfig[i]; | ||
if (this.hostMatch(rule, host)) { | ||
log(LogLevelValues.debug, "getMatchConfig: match host " + host); | ||
return new ParseResult<PluginConfig>(rule.config, true); | ||
@@ -89,3 +89,3 @@ } | ||
if (rule.routes.has(routeName)) { | ||
log(LogLevelValues.debug, "getMatchConfig: match route: " + rule.routes.toString()); | ||
log(LogLevelValues.debug, "getMatchConfig: match route " + routeName); | ||
return new ParseResult<PluginConfig>(rule.config, true); | ||
@@ -92,0 +92,0 @@ } |
{ | ||
"name": "@higress/wasm-assemblyscript", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"main": "assembly/index.ts", | ||
@@ -5,0 +5,0 @@ "scripts": { |
46447
1042