@@ -33,61 +33,63 @@ var _ = Describe("Proxy Suite", func() {
3333 accepted := http.StatusAccepted
3434
3535 upstreams := options.Upstreams{
36− {
37− ID: "http-backend",
38− Path: "/http/",
39− URI: serverAddr,
40− },
41− {
42− ID: "file-backend",
43− Path: "/files/",
44− URI: fmt.Sprintf("file:///%s", filesDir),
45− },
46− {
47− ID: "static-backend",
48− Path: "/static/",
49− Static: true,
50− StaticCode: &ok,
51− },
52− {
53− ID: "static-backend-no-trailing-slash",
54− Path: "/static",
55− Static: true,
56− StaticCode: &accepted,
57− },
58− {
59− ID: "static-backend-long",
60− Path: "/static/long",
61− Static: true,
62− StaticCode: &accepted,
63− },
64− {
65− ID: "bad-http-backend",
66− Path: "/bad-http/",
67− URI: "http://::1",
68− },
69− {
70− ID: "single-path-backend",
71− Path: "/single-path",
72− Static: true,
73− StaticCode: &ok,
74− },
75− {
76− ID: "backend-with-rewrite-prefix",
77− Path: "^/rewrite-prefix/(.*)",
78− RewriteTarget: "/different/backend/path/$1",
79− URI: serverAddr,
80− },
81− {
82− ID: "double-match-plain",
83− Path: "/double-match/",
84− URI: serverAddr,
85− },
86− {
87− ID: "double-match-rewrite",
88− Path: "^/double-match/(.*)",
89− RewriteTarget: "/double-match/rewrite/$1",
90− URI: serverAddr,
36+ Configs: []options.Upstream{
37+ {
38+ ID: "http-backend",
39+ Path: "/http/",
40+ URI: serverAddr,
41+ },
42+ {
43+ ID: "file-backend",
44+ Path: "/files/",
45+ URI: fmt.Sprintf("file:///%s", filesDir),
46+ },
47+ {
48+ ID: "static-backend",
49+ Path: "/static/",
50+ Static: true,
51+ StaticCode: &ok,
52+ },
53+ {
54+ ID: "static-backend-no-trailing-slash",
55+ Path: "/static",
56+ Static: true,
57+ StaticCode: &accepted,
58+ },
59+ {
60+ ID: "static-backend-long",
61+ Path: "/static/long",
62+ Static: true,
63+ StaticCode: &accepted,
64+ },
65+ {
66+ ID: "bad-http-backend",
67+ Path: "/bad-http/",
68+ URI: "http://::1",
69+ },
70+ {
71+ ID: "single-path-backend",
72+ Path: "/single-path",
73+ Static: true,
74+ StaticCode: &ok,
75+ },
76+ {
77+ ID: "backend-with-rewrite-prefix",
78+ Path: "^/rewrite-prefix/(.*)",
79+ RewriteTarget: "/different/backend/path/$1",
80+ URI: serverAddr,
81+ },
82+ {
83+ ID: "double-match-plain",
84+ Path: "/double-match/",
85+ URI: serverAddr,
86+ },
87+ {
88+ ID: "double-match-rewrite",
89+ Path: "^/double-match/(.*)",
90+ RewriteTarget: "/double-match/rewrite/$1",
91+ URI: serverAddr,
92+ },
9193 },
9294 }
9395
@@ -315,8 +317,8 @@ var _ = Describe("Proxy Suite", func() {
315317
316318 Context("sortByPathLongest", func() {
317319 type sortByPathLongestTableInput struct {
318− input options.Upstreams
319− expectedOutput options.Upstreams
320+ input []options.Upstream
321+ expectedOutput []options.Upstream
320322 }
321323
322324 var httpPath = options.Upstream{
@@ -346,40 +348,40 @@ var _ = Describe("Proxy Suite", func() {
346348 Expect(sortByPathLongest(in.input)).To(Equal(in.expectedOutput))
347349 },
348350 Entry("with a mix of paths registered", sortByPathLongestTableInput{
349− input: options.Upstreams{httpPath, httpSubPath, shortSubPathWithRewrite, longerPath, shortPathWithRewrite},
350− expectedOutput: options.Upstreams{shortSubPathWithRewrite, shortPathWithRewrite, longerPath, httpSubPath, httpPath},
351+ input: []options.Upstream{httpPath, httpSubPath, shortSubPathWithRewrite, longerPath, shortPathWithRewrite},
352+ expectedOutput: []options.Upstream{shortSubPathWithRewrite, shortPathWithRewrite, longerPath, httpSubPath, httpPath},
351353 }),
352354 Entry("when a subpath is registered (in order)", sortByPathLongestTableInput{
353− input: options.Upstreams{httpSubPath, httpPath},
354− expectedOutput: options.Upstreams{httpSubPath, httpPath},
355+ input: []options.Upstream{httpSubPath, httpPath},
356+ expectedOutput: []options.Upstream{httpSubPath, httpPath},
355357 }),
356358 Entry("when a subpath is registered (out of order)", sortByPathLongestTableInput{
357− input: options.Upstreams{httpPath, httpSubPath},
358− expectedOutput: options.Upstreams{httpSubPath, httpPath},
359+ input: []options.Upstream{httpPath, httpSubPath},
360+ expectedOutput: []options.Upstream{httpSubPath, httpPath},
359361 }),
360362 Entry("when longer paths are registered (in order)", sortByPathLongestTableInput{
361− input: options.Upstreams{longerPath, httpPath},
362− expectedOutput: options.Upstreams{longerPath, httpPath},
363+ input: []options.Upstream{longerPath, httpPath},
364+ expectedOutput: []options.Upstream{longerPath, httpPath},
363365 }),
364366 Entry("when longer paths are registered (out of order)", sortByPathLongestTableInput{
365− input: options.Upstreams{httpPath, longerPath},
366− expectedOutput: options.Upstreams{longerPath, httpPath},
367+ input: []options.Upstream{httpPath, longerPath},
368+ expectedOutput: []options.Upstream{longerPath, httpPath},
367369 }),
368370 Entry("when a rewrite target is registered (in order)", sortByPathLongestTableInput{
369− input: options.Upstreams{shortPathWithRewrite, longerPath},
370− expectedOutput: options.Upstreams{shortPathWithRewrite, longerPath},
371+ input: []options.Upstream{shortPathWithRewrite, longerPath},
372+ expectedOutput: []options.Upstream{shortPathWithRewrite, longerPath},
371373 }),
372374 Entry("when a rewrite target is registered (out of order)", sortByPathLongestTableInput{
373− input: options.Upstreams{longerPath, shortPathWithRewrite},
374− expectedOutput: options.Upstreams{shortPathWithRewrite, longerPath},
375+ input: []options.Upstream{longerPath, shortPathWithRewrite},
376+ expectedOutput: []options.Upstream{shortPathWithRewrite, longerPath},
375377 }),
376378 Entry("with multiple rewrite targets registered (in order)", sortByPathLongestTableInput{
377− input: options.Upstreams{shortSubPathWithRewrite, shortPathWithRewrite},
378− expectedOutput: options.Upstreams{shortSubPathWithRewrite, shortPathWithRewrite},
379+ input: []options.Upstream{shortSubPathWithRewrite, shortPathWithRewrite},
380+ expectedOutput: []options.Upstream{shortSubPathWithRewrite, shortPathWithRewrite},
379381 }),
380382 Entry("with multiple rewrite targets registered (out of order)", sortByPathLongestTableInput{
381− input: options.Upstreams{shortPathWithRewrite, shortSubPathWithRewrite},
382− expectedOutput: options.Upstreams{shortSubPathWithRewrite, shortPathWithRewrite},
383+ input: []options.Upstream{shortPathWithRewrite, shortSubPathWithRewrite},
384+ expectedOutput: []options.Upstream{shortSubPathWithRewrite, shortPathWithRewrite},
383385 }),
384386 )
385387 })