Source code for Making Envoy contributions Feasible for Everyone
talk at KubeCon 2020
.
See instructions on NodeJS.
$ make npm
$ curl -L https://getenvoy.io/cli | bash -s -- -b /usr/local/bin
$ getenvoy fetch wasm:nightly
To start Envoy
, run:
$ make run
To make sample requests, run:
$ make requests
To inspect Envoy
metrics:
$ make stats
assemblyscript/filter.ts:
import { HttpFilter, log } from "./sdk";
export class ApiValidator extends HttpFilter {
constructor(_config: string) {
super();
log.info("hello world!");
}
}
assemblyscript/model.ts:
export class ApiSpec {
operations: Array<Operation>
}
export class Operation {
method: string
path: string
}
assemblyscript/filter.ts:
import { HttpFilter } from "./sdk";
import { ApiSpec } from "./model";
export class ApiValidator extends HttpFilter {
private spec: ApiSpec
constructor(config: string) {
super();
this.spec = ApiSpec.parse(config);
}
}
assemblyscript/filter.ts:
import { HttpFilter, log, ops } from "./sdk";
import { ApiSpec } from "./model";
export class ApiValidator extends HttpFilter {
private spec: ApiSpec
constructor(config: string) {
super();
this.spec = ApiSpec.parse(config);
}
onExchangeComplete(): void {
let method = ops.getRequestHeader(":method")
let path = ops.getRequestHeader(":path")
if (!this.spec.contains(method, path)) {
log.warn("unknown API: " + method + " " + path);
}
}
}
assemblyscript/filter.ts:
import { HttpFilter, Stats, log, ops } from "./sdk";
import { ApiSpec } from "./model";
export class ApiValidator extends HttpFilter {
private spec: ApiSpec
constructor(config: string) {
super();
this.spec = ApiSpec.parse(config);
}
onExchangeComplete(): void {
let method = ops.getRequestHeader(":method")
let path = ops.getRequestHeader(":path")
if (!this.spec.contains(method, path)) {
log.warn("unknown API: " + method + " " + path);
}
if (!this.spec.contains(method, path)) {
Stats.counter("api_validator.violations_total").inc();
}
}
}