algoliasearch.internal.interceptor.UserAgentInterceptor.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of algoliasearch-scala_3 Show documentation
Show all versions of algoliasearch-scala_3 Show documentation
Scala client for Algolia Search API
package algoliasearch.internal.interceptor
import algoliasearch.internal.AlgoliaAgent
import okhttp3.{Interceptor, Request, Response}
/** Interceptor that adds the user agent to the request headers.
*
* @param agent
* user agent
*/
private[algoliasearch] class UserAgentInterceptor(agent: AlgoliaAgent) extends Interceptor {
override def intercept(chain: Interceptor.Chain): Response = {
val originalRequest: Request = chain.request()
val newRequest: Request = originalRequest
.newBuilder()
.header("user-agent", agent.toString)
.build()
chain.proceed(newRequest)
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy