Cro::CBOR

Support CBOR in Cro for body parsing/serializing

NAME

Cro::CBOR - Support CBOR in Cro for body parsing/serializing

SYNOPSIS

use Cro::CBOR;

# SERVER SIDE
route {
    get -> 'cbor' {
        web-socket :cbor, -> $incoming {             # NOTE `:cbor`
            supply whenever $incoming -> $message {
                my $body = await $message.body;      # NOTE `$message.body` (not -text)
                ... "Generate $response here";
                emit $response;
            }
        }
    }
}

# CLIENT SIDE
my $client     = Cro::CBOR::WebSocket::Client.new(:cbor);
my $connection = await $client.connect: 'http://localhost:12345/cbor';

DESCRIPTION

Cro::CBOR is a set of extensions to Cro::HTTP and Cro::WebSocket to support using CBOR alongside JSON as a standard body serialization format.

If you're already using Cro's automatic JSON serialization, CBOR serialization works very similarly. Replace :json with :cbor, and Cro::WebSocket::Client with Cro::CBOR::WebSocket::Client, and most pieces will Just Work. And if not, please file an issue in the Cro::CBOR repository, and I'll happily take a look.

AUTHOR

Geoffrey Broadwell [email protected]

COPYRIGHT AND LICENSE

Copyright 2021-2025 Geoffrey Broadwell

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.

Cro::CBOR v0.0.7

Support CBOR in Cro for body parsing/serializing

Authors

  • Geoffrey Broadwell

License

Artistic-2.0

Dependencies

CBOR::Simple:ver<0.0.9+>Cro::HTTP:ver<0.8.5+>Cro::WebSocket:ver<0.8.5+>

Test Dependencies

Provides

  • Cro::CBOR

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.

Built with Podlite — the markup and publishing tools behind this site.