Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Revision history for Perl module Mojo::WebSocketProxy

{{$NEXT}}
Add warning with transaction details failure, if available.
Add optional localization callback

0.07 2017-08-29 03:04:42 UTC 2017
Add binary_frame hook to capture binary uploaded data.
Expand Down
2 changes: 2 additions & 0 deletions dist.ini
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ perltidyrc = t/rc/.perltidyrc
[Test::Compile]
[Test::Synopsis]
[Test::EOL]
finder = :InstallModules
finder = :ExecFiles
[Test::Version]
[Test::Pod::LinkCheck]
[PodCoverageTests]
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/WebSocketProxy/CallingEngine.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use warnings;

use MojoX::JSON::RPC::Client;
use Guard;
use JSON;
use JSON::MaybeXS;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cpanfile needs updating? Although I'd suggest better to use Mojo::JSON, that way 3rd-party users get consistent handling across Mojolicious code.


## VERSION

Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/WebSocketProxy/Dispatcher.pm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use Mojo::WebSocketProxy::CallingEngine;

use Class::Method::Modifiers;

use Mojo::JSON qw(encode_json);
use JSON::MaybeXS qw(encode_json);
use Future::Utils qw/fmap/;
use Scalar::Util qw(blessed);
use Variable::Disposition qw(dispose retain retain_future);
Expand Down
9 changes: 6 additions & 3 deletions lib/Mojolicious/Plugin/WebSocketProxy.pm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ sub register {

die 'No base path found!' unless $config->{base_path};

my $localizer = (ref($config->{localizer}) // '?') eq 'CODE'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for the // fallback here, ref returns an empty string for non-refs/undef. However, I'd suggest better to make it $config->{localizer} || sub { $_[1] } otherwise it's silently ignoring invalid parameters such as localizer => "some_helper_name".

? $config->{localizer}
: sub { $_[1] };

my $url_setter;
$url_setter = delete $config->{url} if $config->{url} and ref($config->{url}) eq 'CODE';
$app->helper(
Expand All @@ -24,12 +28,11 @@ sub register {
});
$app->helper(
wsp_error => sub {
shift; # $c
my ($msg_type, $code, $message, $details) = @_;
my ($c, $msg_type, $code, $message, $details) = @_;

my $error = {
code => $code,
message => $message
message => $localizer->($c, $message),
};
$error->{details} = $details if ref($details) eq 'HASH' && keys %$details;

Expand Down