Open kfigiela opened 5 years ago
While in this particular place (ie. modifyPath
) this makes total sense, I am not sure what to do about storage in the cassette yaml file.
Maybe I am misunderstanding but if we don't know the encoding apriori, then the only safe way of encoding the URL (and also headers, query, body etc) would be to treat them as binary, which would result in a unreadable cassette file.
I would be in favour of leaving the rest of the code as is for the moment and fixing the problem if we run into it. (The most probable first occurrence of the problem would be with a binary request body or response).
Stuff left todo (from slack):
[ ] Clients using the proxy will need to wait for the proxy process to start
we could add a test endpoint so that the client can poll to see if proxy is up
output something to stdout when the proxy has started
[ ] Env variables
Kamil had the idea to use environment variables to switch the mode to Record, so it could be used in tests like:
VCR_MODE=Record stack test --ta "-m dotpay"
which would result in a unreadable cassette file
Hmm… welcome to world of encoding or escaping stuff. We can leave this for now if it works. Did you check what happens if we get gzipped response?
https://github.com/restaumatic/vcr-proxy/blob/125154506e36495b1521d2a36b5354d18c3f8789/src/Network/VCR.hs#L29
Several notes:
I'd go for
optparse-applicative
instead manual pattern matching.endpoint
argument is not used for replaying at all, confusing[x] Pokemon exception handling? https://github.com/restaumatic/vcr-proxy/blob/125154506e36495b1521d2a36b5354d18c3f8789/src/Network/VCR.hs#L46 Maybe at least print exception to the console?
[x] Use 502 as default error handler (minor) https://github.com/restaumatic/vcr-proxy/blob/125154506e36495b1521d2a36b5354d18c3f8789/src/Network/VCR.hs#L51 https://github.com/restaumatic/vcr-proxy/blob/125154506e36495b1521d2a36b5354d18c3f8789/src/Network/VCR/Middleware.hs#L86
[x] Endpoint not stored in the casette https://github.com/restaumatic/vcr-proxy/blob/125154506e36495b1521d2a36b5354d18c3f8789/src/Network/VCR/Types.hs#L39 I'd add it for future reference.
[ ] UTF-8 handling Not sure if this will be a problem in practice, but AFARI there is no standard that tells that urls have to be UTF-8 encoded. Perhaps we should operate on ByteStrings? https://github.com/restaumatic/vcr-proxy/blob/125154506e36495b1521d2a36b5354d18c3f8789/src/Network/VCR/Middleware.hs#L104
[x] Executable name https://github.com/restaumatic/vcr-proxy/blob/125154506e36495b1521d2a36b5354d18c3f8789/package.yaml#L48 Perhaps we could just call it
vcr-proxy
?