Mojolicious::Plugin::WebSocketProxy
# 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/', } ); }
attr, import, new, tap
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.
Mojolicious::Plugin::WebSocketProxy, Mojo::WebSocketProxy Mojo::WebSocketProxy::Backend, Mojo::WebSocketProxy::Dispatcher Mojo::WebSocketProxy::Config Mojo::WebSocketProxy::Parser
To install Mojo::WebSocketProxy, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojo::WebSocketProxy
CPAN shell
perl -MCPAN -e shell install Mojo::WebSocketProxy
For more information on module installation, please visit the detailed CPAN module installation guide.