gbmcweb: enable static uri precendence in routing for all plugins
Previously routing was looking for first match for URI only if there is
platforms plugin enabled. But other plugins might also have URI override
i.e fixed routing to override dynamic one. Common google plugins already
has such case. So applying the routing logic for all plugins instead of
only platforms plugin.
Tested: https://paste.googleplex.com/6729195178819584
Google-Bug-Id: 405059942
PiperOrigin-RevId: 823607811
Change-Id: Ib4c027e6b958281197a8d4958fb82ed51e04dbb6
diff --git a/http/routing.cpp b/http/routing.cpp
index c43a468..a67a389 100644
--- a/http/routing.cpp
+++ b/http/routing.cpp
@@ -193,10 +193,12 @@
// vector
bool replaceFound = found == 0U || found > ret.first;
- // For platforms with plugins enabled, we will return the first matched
+ // With plugins enabled, we will return the first matched
// found instead. This results in matching fixed URI segments whenever
// possible relative to wildcards.
-#ifdef PLATFORM_PLUGINS_ENABLED
+#if defined(PLATFORM_PLUGINS_ENABLED) || \
+ defined(GOOGLE_COMMON_PLUGINS_ENABLED) || \
+ defined(GOOGLE_PLUGINS_INTERNAL_ENABLED)
replaceFound = found == 0U;
#endif
diff --git a/test/http/router_test.cpp b/test/http/router_test.cpp
index d2d11c0..e5b2cfa 100644
--- a/test/http/router_test.cpp
+++ b/test/http/router_test.cpp
@@ -156,7 +156,9 @@
EXPECT_EQ(trie.find("/redfish/v1/random/path/here").first, 5);
}
-#ifndef PLATFORM_PLUGINS_ENABLED
+#if !defined(PLATFORM_PLUGINS_ENABLED) && \
+ !defined(GOOGLE_COMMON_PLUGINS_ENABLED) && \
+ !defined(GOOGLE_PLUGINS_INTERNAL_ENABLED)
TEST(Trie, TrieTestReturnsLowestIndexWhenUrlMatchesMultipleRules) {
Trie trie;
@@ -168,7 +170,9 @@
}
#endif
-#ifdef PLATFORM_PLUGINS_ENABLED
+#if defined(PLATFORM_PLUGINS_ENABLED) || \
+ defined(GOOGLE_COMMON_PLUGINS_ENABLED) || \
+ defined(GOOGLE_PLUGINS_INTERNAL_ENABLED)
TEST(Trie, TrieReturnsFixedPathBeforeWildCard) {
Trie trie;