[web-devel] proxy with wai

Jos van den Oever jos at vandenoever.info
Fri Mar 6 08:58:49 UTC 2015


Hello all,

I'm studying the Yesod book by Michael Snoyman and I'm slowly coming to grips 
with Haskell for the web.

My current goal is to write an http(s) proxy that does filtering and caching. 
I've found a nice example by Snoyman on github:
  https://gist.github.com/snoyberg/8779671

This code does not compile with wai >= 3 because that does not have 
responseSourceBracket any more. What is the best way to replace it?

---
Wai.responseSourceBracket (HCl.responseOpen req2 man) (HCl.responseClose) $ 
\res -> do
	let body = mapOutput (Chunk . fromByteString) $ HCC.bodyReaderSource $ 
HCl.responseBody res
		headers = filter safeResHeader $ HCl.responseHeaders res
	return (HCl.responseStatus res, headers, body) 
----

Best regards,
Jos van den Oever


More information about the web-devel mailing list