NAME

Mojolicious::Plugin::WebSocketProxy

SYNOPSYS

 # lib/your-application.pm

 use base 'Mojolicious';

 sub startup {
     my $self = shift;
     $self->plugin(
         'web_socket_proxy' => {
             actions => [
                 ['json_key', {some_param => 'some_value'}]
             ],
             base_path => '/api',
             url => 'http://rpc-host.com:8080/',
         }
     );
}

Or to manually call RPC server:

 # lib/your-application.pm

 use base 'Mojolicious';

 sub startup {
     my $self = shift;
     $self->plugin(
         'web_socket_proxy' => {
             actions => [
                 [
                     'json_key',
                     {
                         instead_of_forward => sub {
                             shift->call_rpc({
                                 args => $args,
                                 method => $rpc_method, # it'll call 'http://rpc-host.com:8080/rpc_method'
                                 rpc_response_cb => sub {...}
                             });
                         }
                     }
                 ]
             ],
             base_path => '/api',
             url => 'http://rpc-host.com:8080/',
         }
     );
}

DESCRIPTION

Using this module you can forward websocket JSON-RPC 2.0 requests to RPC server. See Mojo::WebSocketProxy for details on how to use hooks and parameters.

SEE ALSO

Mojolicious::Plugin::WebSocketProxy, Mojo::WebSocketProxy Mojo::WebSocketProxy::Backend, Mojo::WebSocketProxy::Dispatcher Mojo::WebSocketProxy::Config Mojo::WebSocketProxy::Parser