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

PSGI protocol for HTTP::Tiny #34

Open
djzort opened this issue Apr 3, 2019 · 11 comments
Open

PSGI protocol for HTTP::Tiny #34

djzort opened this issue Apr 3, 2019 · 11 comments

Comments

@djzort
Copy link

djzort commented Apr 3, 2019

The https://metacpan.org/pod/LWP::Protocol::PSGI module allows you to provide code that will called to respond to requests you make with LWP, rather than them going off to a server.

A GSoC student would author something analogous, but for HTTP::Tiny.

The pod of LWP::Protocol::PSGI has a good example, where a trivial dancer app is loaded to respond to LWP requests to google.com. In a test file, an author can mock a web service without having to start up a http daemon of some sort, and doesnt need to insert shims in their code either. Another example from the real world is https://metacpan.org/source/HAKOBE/WebService-SyoboiCalendar-0.02/t/lib/SyobocalMock.pm. The code being tested in entirely unaware of the subterfuge.

A version for HTTP::Tiny would do something very similar. Authors of code using HTTP::Tiny could use this new HTTP::Tiny w/ PSGI in their test suites to mock web services they want to test against.

LWP is multiprotocol, so lends itself to having PSGI added. For HTTP::Tiny to speak to something via PSGI, the Student would need to do something like:

  • Fake HTTP::Tiny entirely, with a module that would be loaded prior to HTTP::Tiny and trick perl in to not loading it. For example:

use HTTP::Tiny::FakeViaPSGI; # This fakes the HTTP::Tiny namespace
use HTTP::Tiny; # This then does nothing other than call HTTP::Tiny->import, as %INC already contains an entry for HTTP::Tiny

  • Add hooks in HTTP::Tiny, so that PSGI can be used
  • Other, as suggested by more creative perl people
@djzort djzort changed the title PSGI protocolfor HTTP::Tiny PSGI protocol for HTTP::Tiny Apr 3, 2019
@dr-kd
Copy link

dr-kd commented Apr 3, 2019

This is a really good idea. LWP::Protocol::PSGI demonstrates really deep understanding of how PSGI works. While the final solution is fairly simple (as in the opposite of the "I'm sorry this letter is so long, I didn't have time to write a short one" kind of way) it demonstrates a deep understanding of the way everything works. Providing an independent demonstration of that depth of understanding would be really useful.

@JJ
Copy link
Contributor

JJ commented Apr 3, 2019

Is this an idea that you are proposing to work with during GSoC? Would anyone here be willing to mentor it?

@dr-kd
Copy link

dr-kd commented Apr 3, 2019

neither of us have sufficient student status. It's a suggested project. Highly constrained problem space, and just tricky enough to be interesting thus high probability of success.

@JJ
Copy link
Contributor

JJ commented Apr 3, 2019 via email

@djzort
Copy link
Author

djzort commented Apr 3, 2019

:(

@JJ
Copy link
Contributor

JJ commented Apr 3, 2019

Well, who knows, someone might find it and be interested... But in that case, I would very strongly suggest that you propose yourself as a mentor, or find someone who would be willing to do so. Mentoring is a nice contribution to the community, and you learn a lot...

@djzort
Copy link
Author

djzort commented Apr 3, 2019

Mentoring a newborn on life is currently dominating my time :) Thanks though.

@tmetro
Copy link

tmetro commented Apr 3, 2019

I chatted with @djzort about this on #soc-help and would be fine with mentoring a student on it.

@JJ
Copy link
Contributor

JJ commented Apr 4, 2019 via email

@djzort
Copy link
Author

djzort commented Sep 26, 2019

See also chansen/p5-http-tiny#130

@djzort
Copy link
Author

djzort commented Jan 21, 2020

I have rolled this in to 2020 perl-foundation-outreach/gsoc-2020-ideas#5

Assuming @tmetro and @singingfish are still ok

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

No branches or pull requests

4 participants