Plack-Middleware-Signposting

 view release on metacpan or  search on metacpan

lib/Plack/Middleware/Signposting/Catmandu.pm  view on Meta::CPAN

            last;
        }
    }

    return $res unless $id;

    # see http://search.cpan.org/~miyagawa/Plack-1.0044/lib/Plack/Middleware.pm#RESPONSE_CALLBACK
    return $self->response_cb($res, sub {
        my $res = shift;

        # ignore streaming response for now
        return unless ref $res->[2] eq 'ARRAY';

        my $data = $bag->get($id) || return;

        $fixer->fix($data);

        # add information to the 'Link' header
        if ($data->{signs}) {
            Plack::Util::header_push(
                $res->[1],

lib/Plack/Middleware/Signposting/JSON.pm  view on Meta::CPAN

    # only get/head requests
    return $res unless $request->method =~ m{^get|head$}i;

    # see http://search.cpan.org/~miyagawa/Plack-1.0044/lib/Plack/Middleware.pm#RESPONSE_CALLBACK
    return $self->response_cb($res, sub {
        my $res = shift;

        my $content_type = Plack::Util::header_get($res->[1], 'Content-Type') || '';
        # only json responses
        return unless $content_type =~ m{^application/json|application\/vnd\.api\+json}i;
        # ignore streaming response for now
        return unless ref $res->[2] eq 'ARRAY';

        my $body = join('', @{$res->[2]});
        my $data = decode_json($body);

        if (ref $data && ref $data eq 'ARRAY') {
            $data = $data->[0];
        }

        my $fix = $self->fix ? $self->fix : 'nothing()';



( run in 0.232 second using v1.01-cache-2.11-cpan-4d50c553e7e )