Skip to content

Commit

Permalink
PubSub: fix missing apikey header to resolve schemas (close #468)
Browse files Browse the repository at this point in the history
  • Loading branch information
oguzhanunlu committed May 20, 2021
1 parent 321dd29 commit f724a89
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import cats.effect.Sync
import io.circe.Json
import org.http4s.circe._
import org.http4s.client.{Client => HttpClient}
import org.http4s.{EntityDecoder, Uri}

import org.http4s.{EntityDecoder, Header, Headers, Request, Uri}
import com.snowplowanalytics.iglu.core.{SchemaKey, SchemaList}
import com.snowplowanalytics.iglu.core.circe.CirceIgluCodecs._
import org.http4s.Method.GET

object Http4sRegistryLookup {

Expand Down Expand Up @@ -53,7 +53,9 @@ object Http4sRegistryLookup {
): EitherT[F, RegistryError, Json] =
for {
uri <- EitherT.fromEither[F](toPath(http, key))
json <- EitherT(Sync[F].attempt(client.expect[Json](uri))).leftMap[RegistryError] { e =>
headers = http.apikey.fold[Headers](Headers.empty)(apikey => Headers.of(Header("apikey", apikey)))
request = Request[F](method = GET, uri = uri, headers = headers)
json <- EitherT(Sync[F].attempt(client.expect[Json](request))).leftMap[RegistryError] { e =>
val error = s"Unexpected exception fetching: $e"
RegistryError.RepoFailure(error)
}
Expand Down

0 comments on commit f724a89

Please sign in to comment.