http4s
http4s copied to clipboard
History Client Middleware
Browsers Keep a history of calls made by the browser. Would be nice if we had a client middleware which did similar in case we ever want to show and capture the interactions that a specific flow may have generated without leaking confidential information like headers/cookies/etc.
// Browser save Title HTML and Favicon - Maybe a later pass maybe just options that are none for now to keep bincompat
// Maybe we want a builder class for this so we can add additional information to it.
def middleware[F[_]: MonadCancelThrow](client: Client[F], history: Ref[F, List[(HttpDate, Method, Uri)], maxSize: Int): Client[F] = Client[F]{(req: Request[F]) =>
Resource.eval(req.headers.get[Date].fold(HttpDate.now[F])(d => d.date.pure[F]).flatMap{ date =>
val allTheOtherStuff
history.modify(l => event :: l) >>
dropElementsAfterN >>
clinet.run(req)
}
} // obviously psuedo
I'll take a look!
@ChristopherDavenport do I need special permission to push up my branch? I was trying to push up my wip branch but got the following error:
ERROR: Permission to http4s/http4s.git denied to SallyPerez.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
@SallyPerez Thanks for your work on this! Indeed, you cannot push a branch to this repository. But you can create your own fork, push there, and start a pull request :)
https://docs.github.com/en/get-started/quickstart/contributing-to-projects
Let us know if you have any questions!!
@armanbilge apologies for not updating here, I've have been working on this and am almost done, working on adding a test for it before submitting a PR
@gringrape Thanks for volunteering, and for your work on the client docs. There are still plenty more issues, and we'd still love to have the help elsewhere!
@gringrape Thanks for volunteering, and for your work on the client docs. There are still plenty more issues, and we'd still love to have the help elsewhere!
Thank you! Actually, I'd love to contribute more. I'll check issues. :)
@rossabaker is this something that you are still wanted to achieve? I would like to help because it is something that on my daily use case it is interesting. @SallyPerez If you are interested into I can help you on this.
Thanks for the offers of help, but it's in active progress.
It's in progress. Thanks for the offer @albertoadami