After looking at the code for the module (well, almost), I think your assumption is right. You cannot have two modules for the same path.
elsif (ref $arg[0] eq 'HASH') { # Lazy loading
for my $path (keys %{$arg[0]}) {
my $pkg = $arg[0]->{$path};
$self->{dispatch_path}->{$path} = $pkg;
}
}
It will accept multiple key/value pairs of paths and modules in dispatch, so there is no need to call dispatch twice. But it will only allow one module per path. Your second call to dispatch
with sub2Num
was overwriting the previously set add2Num
.
Without trying anything of this, I see a few solutions:
- use the array ref syntax
dispatch(['add2Num', 'sub2Num')
and figure out where to set the path that the daemon is bound to (most likely) - build an additional module which imports both
add2Num
andsub2Num
to combine them anddispatch({'/jsonrpc/API' => 'combinedNum})
- add the support you need to the module and submit it as a patch to the author (least likely)