I want to use custom ManagerSettings to build a custom Network.Wreq.Session. I modify from the defaultManagerSettings both managerRawConnection and managerModifyRequest.
I want managerModifyRequest to use a configuration value known at runtime from a file. As I do a lot of requests, I would rather not make a lot of syscalls to get the configuration value from the file.
I find the type managerModifyRequest :: Request -> IO Request to be problematic. How can I use a configuration value if it is not possible to get it from the parameters?
I thought about IORefs and MVars to store the value in memory, but I should be able to pass said IORef or MVar to the function somehow...
I am not familiar with the library, but I guess you need to write something like this:
You don't need to pass the
IORefas an additional argument tomanagerModifyRequest, you need to define thatRequest -> IO Requestfunction in the scope where theIORefis available.Alternatively, use an helper function with the additional argument, and then partially apply it with the
IORef: