Hideout/templates/libraries/spring-cloud/apiKeyRequestInterceptor.mu...

20 lines
424 B
Plaintext
Raw Normal View History

2023-10-08 06:06:06 +00:00
package {{configPackage}}
import feign.RequestInterceptor
import feign.RequestTemplate
class ApiKeyRequestInterceptor(
private val location: String,
private val name: String,
private val value: String,
) : RequestInterceptor {
override fun apply(requestTemplate: RequestTemplate) {
if (location == "header") {
requestTemplate.header(name, value)
} else if (location == "query") {
requestTemplate.query(name, value)
}
}
}