示例#1
0
func checkInitial(rd skipper.RawData) bool {
	d, err := eskip.Parse(rd.Get())
	if err != nil {
		return false
	}

	if len(d) != 1 {
		return false
	}

	r := d[0]

	if r.Id != "pdp" {
		return false
	}

	if r.MatchExp != "PathRegexp(`.*\\.html`)" {
		return false
	}

	if len(r.Filters) != 2 {
		return false
	}

	checkFilter := func(f *eskip.Filter, name string, args ...interface{}) bool {
		if f.Name != name {
			return false
		}

		if len(f.Args) != len(args) {
			return false
		}

		for i, a := range args {
			if f.Args[i] != a {
				return false
			}
		}

		return true
	}

	if !checkFilter(r.Filters[0], "customHeader", 3.14) {
		return false
	}

	if !checkFilter(r.Filters[1], "xSessionId", "v4") {
		return false
	}

	if r.Backend != "https://www.zalando.de" {
		return false
	}

	return true
}
示例#2
0
func checkBackend(rd skipper.RawData, routeId, backend string) bool {
	d, err := eskip.Parse(rd.Get())
	if err != nil {
		return false
	}

	for _, r := range d {
		if r.Id == routeId {
			return r.Backend == backend
		}
	}

	return false
}