File tree Expand file tree Collapse file tree 1 file changed +18
-16
lines changed
Expand file tree Collapse file tree 1 file changed +18
-16
lines changed Original file line number Diff line number Diff line change @@ -23,27 +23,29 @@ func (a *ReqPathRewrite) GetName() string {
2323}
2424
2525func (a * ReqPathRewrite ) Process (k store.K8s , annotations ... map [string ]string ) (err error ) {
26- input := common .GetValue (a .GetName (), annotations ... )
26+ input := strings . TrimSpace ( common .GetValue (a .GetName (), annotations ... ) )
2727 if input == "" {
2828 return
2929 }
30- parts := strings .Fields (strings .TrimSpace (input ))
30+ for _ , rule := range strings .Split (input , "\n " ) {
31+ parts := strings .Fields (strings .TrimSpace (rule ))
3132
32- var rewrite * rules.ReqPathRewrite
33- switch len (parts ) {
34- case 1 :
35- rewrite = & rules.ReqPathRewrite {
36- PathMatch : "(.*)" ,
37- PathFmt : parts [0 ],
33+ var rewrite * rules.ReqPathRewrite
34+ switch len (parts ) {
35+ case 1 :
36+ rewrite = & rules.ReqPathRewrite {
37+ PathMatch : "(.*)" ,
38+ PathFmt : parts [0 ],
39+ }
40+ case 2 :
41+ rewrite = & rules.ReqPathRewrite {
42+ PathMatch : parts [0 ],
43+ PathFmt : parts [1 ],
44+ }
45+ default :
46+ return fmt .Errorf ("incorrect value '%s', path-rewrite takes 1 or 2 params " , input )
3847 }
39- case 2 :
40- rewrite = & rules.ReqPathRewrite {
41- PathMatch : parts [0 ],
42- PathFmt : parts [1 ],
43- }
44- default :
45- return fmt .Errorf ("incorrect value '%s', path-rewrite takes 1 or 2 params " , input )
48+ a .rules .Add (rewrite )
4649 }
47- a .rules .Add (rewrite )
4850 return
4951}
You can’t perform that action at this time.
0 commit comments