Skip to content

Commit

Permalink
MINOR: remove redundancy in AddCustomRoute function logic
Browse files Browse the repository at this point in the history
Refactors the `AddCustomRoute` function to eliminate redundancy introduced in commit c28d620.
The updated code removes repetition without add extra spaces.
  • Loading branch information
fabianonunes committed Jan 9, 2025
1 parent 16d143b commit 1fba224
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions pkg/route/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,9 @@ func AddCustomRoute(route Route, routeACLAnn string, api api.HAProxyClient) (err
}
if route.Path.Path != "" {
if route.Path.PathTypeMatch == store.PATH_TYPE_EXACT {
if routeCond == "" {
routeCond = fmt.Sprintf("{ path %s }", route.Path.Path)
} else {
routeCond = fmt.Sprintf("%s { path %s }", routeCond, route.Path.Path)
}
routeCond = fmt.Sprintf("%s{ path %s }", routeCond, route.Path.Path)
} else {
if routeCond == "" {
routeCond = fmt.Sprintf("{ path -m beg %s }", route.Path.Path)
} else {
routeCond = fmt.Sprintf("%s { path -m beg %s }", routeCond, route.Path.Path)
}
routeCond = fmt.Sprintf("%s{ path -m beg %s }", routeCond, route.Path.Path)
}
}
routeCond = fmt.Sprintf("%s { %s } ", routeCond, routeACLAnn)
Expand Down

0 comments on commit 1fba224

Please sign in to comment.