Kelp

 view release on metacpan or  search on metacpan

lib/Kelp/Manual/Cookbook.pod  view on Meta::CPAN


        # call the original $self->template again
        # with modified arguments
        return $self->$orig(@args);
    };

=head2 Handling websocket connections

Since Kelp is a Plack-based project, its support for websockets is very
limited. First of all, you would need a Plack server with support for the psgi
I<streaming>, I<io> and I<nonblocking>, like L<Twiggy>. Then, you could
integrate Kelp application with a websocket application via
L<Kelp::Module::Websocket::AnyEvent> CPAN module (if the server implementation
is compatible with L<AnyEvent>):

    sub build {
        my ($self) = @_;

        my $ws = $self->websocket;
        $ws->add(message => sub {
            my ($conn, $msg) = @_;

lib/Kelp/Response.pm  view on Meta::CPAN

=head2 rendered

Tells if the response has been rendered. This attribute is used internally and
unless you know what you're doing, we recommend that you do not use it.

=head2 partial

Sets partial response. If this attribute is set to a true value, it will cause
C<finalize> to return the HTTP status code and headers, but not the body. This is
convenient if you intend to stream your content. In the following example, we
set C<partial> to 1 and use C<finalize> to get a C<writer> object for streaming.

    sub stream {
        my $self = shift;
        return sub {
            my $responder = shift;

            # Stream JSON
            $self->res->set_code(200)->json->partial(1);

            # finalize will now return only the status code and headers



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