aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/main/java/org/onap/vid/logging/Headers.kt
blob: cc5ebf38cc8c42ca5a7ab37d44e26aa4a396abf6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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()) }
    }
}