-
-
Save FCO/e08b717af876276602428f8147c08b7e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ raku -MCro::HTTP::Server -MCro::HTTP::Router -e ' | |
Cro::HTTP::Server.new( | |
host => "127.0.0.1", | |
port => 10001, | |
application => route {my $CRO-ROUTER-RESPONSE = $*CRO-ROUTER-RESPONSE; | |
get -> {content "test/plain", "ok!"} | |
^3 .map: -> $i { | |
post -> Int $a where { say "$_ == $i -> { $_ == $i }"; $_ == $i } { | |
CATCH { default { say "ERROR: $_" } } | |
request-body -> %data { | |
dd %data; | |
say "running $a == $i"; | |
content "test/plain", "ok" | |
} | |
} | |
} | |
} | |
).start; | |
react whenever signal(SIGINT) {exit} | |
' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ curl -v 127.0.0.1:10001/2 -d a=b | |
* Trying 127.0.0.1:10001... | |
* Connected to 127.0.0.1 (127.0.0.1) port 10001 (#0) | |
> POST /2 HTTP/1.1 | |
> Host: 127.0.0.1:10001 | |
> User-Agent: curl/7.79.1 | |
> Accept: */* | |
> Content-Length: 3 | |
> Content-Type: application/x-www-form-urlencoded | |
> | |
* Mark bundle as not supporting multiuse | |
< HTTP/1.1 500 Internal Server Error | |
< Transfer-encoding: chunked | |
< | |
* Connection #0 to host 127.0.0.1 left intact |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 == 2 -> True | |
2 == 0 -> False | |
2 == 0 -> False | |
Constraint type check failed in binding to parameter '$a'; expected anonymous constraint to be met but got Int (2) | |
in block at -e line 9 | |
in block at /Users/fernandooliveira/.rakubrew/versions/moar-main/install/share/perl6/site/sources/0A956E7216D9483D5E509D21341F86CD95BF92D0 (Cro::HTTP::Router) line 201 | |
in block at /Users/fernandooliveira/.rakubrew/versions/moar-main/install/share/perl6/site/sources/0A956E7216D9483D5E509D21341F86CD95BF92D0 (Cro::HTTP::Router) line 197 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment