Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom HTTP/S agents #91

Open
felixSchl opened this issue Jan 12, 2017 · 3 comments
Open

Custom HTTP/S agents #91

felixSchl opened this issue Jan 12, 2017 · 3 comments

Comments

@felixSchl
Copy link

xhr2 allows using a custom http/s agent for node: https://github.com/pwnall/node-xhr2/blob/567ec5f41f94f0bcb6d6b1f917be6506f43ce49a/src/001-xml_http_request.coffee#L262-L265.

It would be great if this could be set somehow, but not sure how this fits with purescript.

My usecase is wanting to plug in a proxying agent.

@garyb
Copy link
Member

garyb commented Jan 23, 2017

This answer applies to both this and #92:

I think we'll have to split Affjax's interface from its implementation if we want to support non-browser-XHR features, perhaps using https://github.com/slamdata/purescript-affjax-algebra or a typeclass or something. I don't really have time to work on it myself right now though.

Sorry about the slow reply!

@felixSchl
Copy link
Author

I am interested in investing time into that. What method (typeclass, free monad) would be preferred and more importantly why? Is there another approach?

@garyb
Copy link
Member

garyb commented Jan 24, 2017

I guess since the algebra is already done just writing an alternative interpreter for that would be the fastest way to get this working, so I'd probably go with that.

The typeclass approach might be slight easier to defer to the main of the program as it can propagate as a constraint, so you don't have to explicitly pass the interpreter down, as you could just run it at the top level to turn it into Aff or something.

But generally I prefer the f-algebra approach as it gives you more options: you can (more easily) inspect or modify the requests, there is more flexibility in how the interpreter is implemented (in terms of accepting options, etc.). Also I prefer to avoid lawless typeclasses.

Either option is pretty good really, it's aesthetic as much as anything else. And you can even mix the two.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants