Dancer-Plugin-Tapir

 view release on metacpan or  search on metacpan

lib/Dancer/Plugin/Tapir.pm  view on Meta::CPAN

                    die "Error in composing $method_message_class result: $_\n";
                };
                $status ||= 200;
            }
            # The handler set either 'error' or 'exception'; return a status 500 with a JSON payload describing the problem
            else {
                $status ||= 500;
                $response = $json_xs->encode({ $result_key => $result_value });
            }

            header 'content-type' => 'application/json';
            status $status;
            return $response;
        };

        my $wrapper_sub = sub {
            my $result;
            try {
                $result = $dancer_sub->(@_);
            }
            catch {

lib/Dancer/Plugin/Tapir.pm  view on Meta::CPAN

                    }
                    $logger->error($string_error);
                    $result = $json_xs->encode({
                        error => $string_error,
                    });
                }
                else {
                    $logger->error("$ex");
                    $result = $json_xs->encode({ exception => "$ex" });
                }
                header 'content-type' => 'application/json';
                status $status;
            };

            # Returning the result will print it to the HTTP response
            return $result;
        };

        # Install the route
        {
            no strict 'refs';



( run in 3.124 seconds using v1.01-cache-2.11-cpan-524268b4103 )