Skip to content

Commit e11a367

Browse files
fabianonunesGopher Bot
authored andcommitted
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 1afb634 commit e11a367

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
@@ -109,17 +109,9 @@ func AddCustomRoute(route Route, routeACLAnn string, api api.HAProxyClient) (err
109109
}
110110
if route.Path.Path != "" {
111111
if route.Path.PathTypeMatch == store.PATH_TYPE_EXACT {
112-
if routeCond == "" {
113-
routeCond = fmt.Sprintf("{ path %s }", route.Path.Path)
114-
} else {
115-
routeCond = fmt.Sprintf("%s { path %s }", routeCond, route.Path.Path)
116-
}
112+
routeCond = fmt.Sprintf("%s{ path %s }", routeCond, route.Path.Path)
117113
} else {
118-
if routeCond == "" {
119-
routeCond = fmt.Sprintf("{ path -m beg %s }", route.Path.Path)
120-
} else {
121-
routeCond = fmt.Sprintf("%s { path -m beg %s }", routeCond, route.Path.Path)
122-
}
114+
routeCond = fmt.Sprintf("%s{ path -m beg %s }", routeCond, route.Path.Path)
123115
}
124116
}
125117
routeCond = fmt.Sprintf("%s { %s } ", routeCond, routeACLAnn)

0 commit comments

Comments
 (0)