Closed melezhik closed 1 year ago
Hey @melezhik, the example that is failing is because MyBackend
doesn't actually exists it's more of an example of how to use a different backend, you may omit that and just call listen
without parameters.
For the other one my-user-validation-logic
also is just a stand in for some sort of validation that you could add, you can just get rid of the if statement.
Thanks.
Hi @rawleyfowler , yes I get that, fair enough , what about test number four?
14:36:17 :: ############################################# test_4 ################################################
14:36:17 :: run: [
14:36:17 :: use v6.d;
14:36:17 ::
14:36:17 :: use Humming-Bird::Core;
14:36:17 :: use Humming-Bird::Middleware;
14:36:17 ::
14:36:17 :: get('/logged', -> $request, $response {
14:36:17 :: $response.html('This request has been logged!');
14:36:17 :: }, [ &middleware-logger ]); # &middleware-logger is provided by Humming-Bird::Middleware
14:36:17 ::
14:36:17 :: # Custom middleware
14:36:17 :: sub block-firefox($request, $response, &next) {
14:36:17 :: return $response.status(400) if $request.header('User-Agent').starts-with('Mozilla');
14:36:17 :: $response.status(200);
14:36:17 :: }
14:36:17 ::
14:36:17 :: get('/no-firefox', -> $request, $response {
14:36:17 :: $response.html('You are not using Firefox!');
14:36:17 :: }, [ &middleware-logger, &block-firefox ]);
14:36:17 :: ]
14:36:17 :: pid: 1882
14:36:17 :: =====
14:36:17 :: GET localhost:8080
14:36:17 :: =====
14:36:27 :: =====
14:36:27 :: log:
[task stderr]
14:36:27 :: * Trying [::1]:8080...
14:36:27 :: * Immediate connect fail for ::1: Address not available
14:36:27 :: * Trying 127.0.0.1:8080...
14:36:27 :: * connect to 127.0.0.1 port 8080 failed: Connection refused
14:36:27 :: * Failed to connect to localhost port 8080 after 0 ms: Couldn't connect to server
14:36:27 :: * Closing connection
14:36:27 :: /var/.sparrowdo/env/zef-build/.sparrowdo/tasks/intergration_tests/tasks/smoke_test/task.bash: line 15: kill: (1882) - No such process
It seems the listen call is missing on the end of the script, that is a mistake I will correct, thanks
here we are )) this is why one might need doc test , I am glad it's been useful ))
Thank you for raising the issue, feel free to close this if you think all is good.
Hi @rawleyfowler I am experimenting with some SparrowCI pipeline that allow me to run code example from a module readme page, and this is what I get for Humming Bird - https://ci.sparrowhub.io/report/3817 , HTH
Alexey