perl-foundation-outreach / ideas

Perl Foundation umbrella project ideas for GSoC
https://perl-gsoc-2019.github.io/ideas/
GNU General Public License v3.0
5 stars 12 forks source link

PSGI protocol for HTTP::Tiny #34

Open djzort opened 5 years ago

djzort commented 5 years ago

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:

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

dr-kd commented 5 years ago

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 commented 5 years ago

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

dr-kd commented 5 years ago

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 commented 5 years ago

It's a very interesting idea, but it's 6 days away from final proposal by students. Without mentors, and so late in the game, it's unlikely that's it's taken up by someone. Thanks anyway!

djzort commented 5 years ago

:(

JJ commented 5 years ago

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 commented 5 years ago

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

tmetro commented 5 years ago

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

JJ commented 5 years ago

That would be great. Please prepare then a full document with this and include yourself as mentor. Students will be looking at them.

djzort commented 5 years ago

See also https://github.com/chansen/p5-http-tiny/issues/130

djzort commented 4 years ago

I have rolled this in to 2020 https://github.com/perl-foundation-outreach/gsoc-2020-ideas/pull/5

Assuming @tmetro and @singingfish are still ok