I'm trying to share state between multiple http requests on http4s
server.
That is what I tried:
for {
state <- Ref[F].of(0)
_ <- BlazeServerBuilder[F]
.bindHttp(port, host)
.withHttpApp( ... httpApp that has link to "state" ... )
.serve.compile.lastOrError
} yield ()
The state remains the same after I change it inside http request.
Is it possible to share "state" in a pure FP style using Ref
or something from Fs2
?
UPDATE: the problem was inside my app. not related to how I pass the Ref. my bad.