Skip to content

Commit b2141fa

Browse files
committed
MINOR: remove redundancy in AddCustomRoute function logic
Refactors the `AddCustomRoute` function to eliminate redundancy introduced in commit c28d620. The updated code removes repetition without add extra spaces.
1 parent b7036e4 commit b2141fa

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

pkg/route/route.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,9 @@ func AddCustomRoute(route Route, routeACLAnn string, api api.HAProxyClient) (err
107107
}
108108
if route.Path.Path != "" {
109109
if route.Path.PathTypeMatch == store.PATH_TYPE_EXACT {
110-
if routeCond == "" {
111-
routeCond = fmt.Sprintf("{ path %s }", route.Path.Path)
112-
} else {
113-
routeCond = fmt.Sprintf("%s { path %s }", routeCond, route.Path.Path)
114-
}
110+
routeCond = fmt.Sprintf("%s{ path %s }", routeCond, route.Path.Path)
115111
} else {
116-
if routeCond == "" {
117-
routeCond = fmt.Sprintf("{ path -m beg %s }", route.Path.Path)
118-
} else {
119-
routeCond = fmt.Sprintf("%s { path -m beg %s }", routeCond, route.Path.Path)
120-
}
112+
routeCond = fmt.Sprintf("%s{ path -m beg %s }", routeCond, route.Path.Path)
121113
}
122114
}
123115
routeCond = fmt.Sprintf("%s { %s } ", routeCond, routeACLAnn)

0 commit comments

Comments
 (0)