Skip to content

Middleware examples #513

Answered by Baccata
ahjohannessen asked this question in Q&A
Oct 13, 2022 · 6 comments · 7 replies
Discussion options

You must be logged in to vote

Using IOLocal, the approach for the client-side is essentially the exact dual of the one we document for the server side.

Essentially you'd have a middleware implementing that following signature, responsible for reading context out of the local and writing the headers (when the server-side does the exact opposite, it reads from the headers and writes the context into the local)

def withContext(local: IOLocal[Context], client: Client[IO]) : Client[IO] 

then you'd wrap the IOLocal in some abstraction that would allow for writing to it. Could be a mere Context => IO[Unit], and you pass that to whatever layer of your application has a handle to (or the ability to instantiate) a Context.

class 

Replies: 6 comments 7 replies

Comment options

You must be logged in to vote
4 replies
@ahjohannessen
Comment options

@ahjohannessen
Comment options

@ahjohannessen
Comment options

@kubukoz
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by ahjohannessen
Comment options

You must be logged in to vote
2 replies
@Baccata
Comment options

@Baccata
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@Baccata
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants