All Downloads are FREE. Search and download functionalities are using the official Maven repository.

endpoints4s.sttp.client.BasicAuthentication.scala Maven / Gradle / Ivy

The newest version!
package endpoints4s.sttp.client

import endpoints4s.{Tupler, algebra}
import endpoints4s.algebra.BasicAuthentication.Credentials
import endpoints4s.algebra.Documentation

/** @group interpreters
  */
trait BasicAuthentication[R[_]] extends algebra.BasicAuthentication {
  self: EndpointsWithCustomErrors[R] =>

  private[endpoints4s] def authenticatedRequest[U, E, H, UE, HCred, Out](
      method: Method,
      url: Url[U],
      entity: RequestEntity[E],
      headers: RequestHeaders[H],
      requestDocs: Documentation
  )(implicit
      tuplerUE: Tupler.Aux[U, E, UE],
      tuplerHCred: Tupler.Aux[H, Credentials, HCred],
      tuplerUEHCred: Tupler.Aux[UE, HCred, Out]
  ): Request[Out] = {
    val basicAuthenticationHeader: RequestHeaders[Credentials] =
      (credentials, request) => {
        request.auth.basic(credentials.username, credentials.password)
      }
    request(
      method,
      url,
      entity,
      requestDocs,
      headers ++ basicAuthenticationHeader
    )
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy