-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow setting custom headers to HTTP requests made to Measure servers #1689
Comments
There are two APIs we plan to expose.
measure {
httpHeaders = mapOf(
"key" to "value"
)
} There will be an option to set different headers for a particular variant using the variant filter API. measure {
variantFilter {
httpHeaders = when {
name.contains("debug") -> mapOf("key" to "debug-value")
name.contains("alpha") -> mapOf("key" to "alpha-value")
else -> mapOf("key" to "prod-value")
}
}
}
Measure.init(
context,
MeasureConfig(
requestHttpHeaders = mapOf("key", "value")
)
) |
This works for majority of the use cases, though is there a way to update the MeasureConfig post Or would a reinit work? |
We can expose an API for taking in a ConfigMeasure.init(
context,
MeasureConfig(requestHeadersProvider = CustomHeadersProvider())
) Providerinterface MsrRequestHeadersProvider {
fun getRequestHeaders(): Map<String, String>
} Sample usageclass CustomHeadersProvider: MsrRequestHeadersProvider {
private val headers = ConcurrentHashMap<String, String>()
override fun getRequestHeaders(): Map<String, String> {
return headers.toMap()
}
fun setGatewayAuthHeader(value: String) {
headers["X-Gateway-Token"] = value
}
} |
That should scale for all the use cases. |
Tracking the work need to support his here: #1731 |
Description
Currently, the SDK does not provide a mechanism to add custom HTTP headers to PUT API requests. Users require this to do custom authentication or rate limiting.
Implement a way to configure both the SDK and the gradle plugin to accept custom headers.
The text was updated successfully, but these errors were encountered: