Closed tbrowder closed 7 years ago
Well, it is not precisely a bug, more of a bad error message and a bit of incomplete docs. The problem is that your route doesn't serve any content, hence the error. You can try it as
say "Request headers:";
for request.headers {
say " {.name}: {.value}";
}
content 'plain/text', 'Response';
and it will work.
I will look into prettier error message now.
Made a better error with https://github.com/croservices/cro-http/commit/d6ff33c5a81400e37d1be73a2243db146748835a
Thank you! I admit my knowledge of http client/server architecture is very weak. But CRO seems to be the best and easiest to use I've seen!
Oh, no problem with that. Thanks a lot for your words!
I have added a response line into the example, to prevent this kind of confusion. Can the issue be closed?
Perhaps we should just make the default response be a 204 (No Content), which would be a reasonable default when implementing PUT
and DELETE
in REST APIs, but also would have made examples like the one we see here work sufficiently well.
On Mon, Sep 25, 2017 at 15:11 Altai-man notifications@github.com wrote:
Oh, no problem with that. Thanks a lot for your words!
I have added a response line into the example, to prevent this kind of confusion. Can the issue be closed?
Yes, thanks.
@jnthn we can do it like so, though I dunno is it common enough. If you're suggesting it, we may go with another issue for this case.
PUT and DELETE with a 204 response are common enough when doing a REST API implementation. So I think it's probably a sensible default. Let's go with it.
Done. Closing~
In "http://cro.services/docs/reference/cro-http-router" there is a section named "Accessing the Cro::HTTP::Request instance" with this example:
When I try to use it I get the following exception:
System: Debian 8, 64-bit.
$ perl6 -v This is Rakudo version 2017.08-110-g5f33506 built on MoarVM version 2017.08.1-156-g49b90b9 implementing Perl 6.c.
Complete code is at gist: https://gist.github.com/tbrowder/fc5d4c628561451a9c9ea0ef1f7a2a93