You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use Cro::HTTP::BodySerializers;
use YAML;
class Cro::HTTP::BodySerializer::YAML does Cro::HTTP::BodySerializer {
method is-applicable(Cro::HTTP::Message $message, $body --> Bool)
{
with $message.content-type {
(.type eq 'text' && .subtype eq 'x-yaml') &&
($body ~~ Map || $body ~~ List)
}
else {
False
}
}
method serialize(Cro::HTTP::Message $message, $body --> Supply)
{
my $yaml = yaml.dump($body).encode('utf-8');
self!set-content-length($message, $yaml.bytes);
supply { emit $yaml }
}
}
Note, I used YAML instead of YAMLish... I realize the dependency hell this leads to, so I suspect you won't want it in this repository. (Could make a Cro::HTTP::BodySerializer::YAMLish too..)
Where is the right place for this? Could you put it in a separate croservices repository? Should I simply release it separately to ecosystem through CPAN myself?
The text was updated successfully, but these errors were encountered:
Probably a module that provides both a YAML body parser and body serializer would be good, yes. I agree it doesn't belong in core. Maybe Cro::HTTP::Body::YAML is a decent distribution name, and I'd be good with creating a repo under croservices and having it mentioned in the Cro docs.
I think it is pretty straight forward to clone from JSON and do the YAML parse/dump, but if you don't want to take the time, if you create a mostly empty Cro::HTTP::Body::YAML croservices repo, I'll fork it and give you a PR with some basics and tests to start from.
YAMLish is kind of fundamentally broken, but you could do the same with Cro::HTTP::Body::YAMLish and I'll do that one too.
YAML is kind of broken too, but it is getting there.
I love YAML, but it isn't very mature for Perl 6 yet.
Something like:
Note, I used
YAML
instead ofYAMLish
... I realize the dependency hell this leads to, so I suspect you won't want it in this repository. (Could make aCro::HTTP::BodySerializer::YAMLish
too..)Where is the right place for this? Could you put it in a separate
croservices
repository? Should I simply release it separately to ecosystem through CPAN myself?The text was updated successfully, but these errors were encountered: