Dancer2-Plugin-JsonApi/lib/Dancer2/Serializer/JsonApi.pm

34 lines
631 B
Perl
Raw Normal View History

2023-11-10 20:30:25 +00:00
use 5.38.0;
package Dancer2::Serializer::JsonApi;
use Dancer2::Plugin::JsonApi::Registry;
use Dancer2::Serializer::JSON;
use Moo;
has content_type => ( is => 'ro', default => 'application/vnd.api+json' );
with 'Dancer2::Core::Role::Serializer';
has registry => (
is => 'rw',
default => sub { Dancer2::Plugin::JsonApi::Registry->new }
);
has json_serializer => (
is => 'ro',
default => sub { Dancer2::Serializer::JSON->new }
);
sub serialize {
my ( $self, $data ) = @_;
return $self->json_serializer->serialize(
$self->registry->serialize(@$data) );
2023-11-10 20:30:25 +00:00
}
sub deserialize { ... }
1;