aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/main/java/org/onap/vid/logging/Headers.kt
diff options
context:
space:
mode:
Diffstat (limited to 'vid-app-common/src/main/java/org/onap/vid/logging/Headers.kt')
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/logging/Headers.kt20
1 files changed, 20 insertions, 0 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/logging/Headers.kt b/vid-app-common/src/main/java/org/onap/vid/logging/Headers.kt
new file mode 100644
index 000000000..cc5ebf38c
--- /dev/null
+++ b/vid-app-common/src/main/java/org/onap/vid/logging/Headers.kt
@@ -0,0 +1,20 @@
+package org.onap.vid.logging
+
+import org.onap.portalsdk.core.util.SystemProperties.ECOMP_REQUEST_ID
+import org.springframework.stereotype.Component
+import javax.servlet.http.HttpServletRequest
+
+@Component
+class Headers {
+ fun prioritizedRequestIdHeaders() = listOf(
+ "X-ONAP-RequestID",
+ "X-RequestID",
+ "X-TransactionID",
+ ECOMP_REQUEST_ID
+ )
+
+ fun highestPriorityHeader(httpRequest: HttpServletRequest): String? {
+ val headers = httpRequest.headerNames.asSequence().toSet().map { it.toUpperCase() }
+ return prioritizedRequestIdHeaders().firstOrNull { headers.contains(it.toUpperCase()) }
+ }
+}