-
Notifications
You must be signed in to change notification settings - Fork 5
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
HTTP headers are passed to the default adapter constructor and are used unchanged for each request. But there are situations when HTTP headers need to be generated before each request. For example, to refresh JWT token:
val context = cinemaContextOf(
CinemaCompositeKtorAdapter(
client,
"http://localhost:8080/graphql",
"ws://localhost:8080/subscriptions",
object : CinemaMapper {
override fun serialize(value: Any): String =
mapper.writeValueAsString(value)
override fun <T : Any> deserialize(content: String, contentType: KClass<T>): T =
mapper.readValue(content, contentType.java)
},
mapOf("Authorization" to "Basic YWRtaW46YWRtaW4=") //todo How to refresh JWT token here?
)
)
Let use suspendable lambda to generate HTTP headers before each request:
val context = cinemaContextOf(
CinemaCompositeKtorAdapter(
client,
"http://localhost:8080/graphql",
"ws://localhost:8080/subscriptions",
object : CinemaMapper {
override fun serialize(value: Any): String =
mapper.writeValueAsString(value)
override fun <T : Any> deserialize(content: String, contentType: KClass<T>): T =
mapper.readValue(content, contentType.java)
},
{ mapOf("Authorization" to "Basic YWRtaW46YWRtaW4=") } //todo Let use suspendable lambda here!
)
)
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request