Skip to content

Commit 1fba224

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 16d143b commit 1fba224

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

pkg/route/route.go

+2-10
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,9 @@ func AddCustomRoute(route Route, routeACLAnn string, api api.HAProxyClient) (err
108108
}
109109
if route.Path.Path != "" {
110110
if route.Path.PathTypeMatch == store.PATH_TYPE_EXACT {
111-
if routeCond == "" {
112-
routeCond = fmt.Sprintf("{ path %s }", route.Path.Path)
113-
} else {
114-
routeCond = fmt.Sprintf("%s { path %s }", routeCond, route.Path.Path)
115-
}
111+
routeCond = fmt.Sprintf("%s{ path %s }", routeCond, route.Path.Path)
116112
} else {
117-
if routeCond == "" {
118-
routeCond = fmt.Sprintf("{ path -m beg %s }", route.Path.Path)
119-
} else {
120-
routeCond = fmt.Sprintf("%s { path -m beg %s }", routeCond, route.Path.Path)
121-
}
113+
routeCond = fmt.Sprintf("%s{ path -m beg %s }", routeCond, route.Path.Path)
122114
}
123115
}
124116
routeCond = fmt.Sprintf("%s { %s } ", routeCond, routeACLAnn)

0 commit comments

Comments
 (0)