CGI-Snapp-Dispatch

 view release on metacpan or  search on metacpan

META.json  view on Meta::CPAN

            "CGI::Snapp" : "2.01",
            "Capture::Tiny" : "0.44",
            "Carp" : "1.2",
            "Class::Load" : "0.23",
            "File::Spec" : "3.4",
            "HTTP::Exception" : "0.04001",
            "IO::Pipe" : "1.15",
            "Log::Handler" : "0.88",
            "Moo" : "2.002004",
            "Proc::Fork" : "0.804",
            "Try::Tiny" : "0.27",
            "lib" : "0",
            "parent" : "0.234",
            "strict" : "0",
            "warnings" : "0"
         }
      },
      "test" : {
         "requires" : {
            "Test::Deep" : "0.12",
            "Test::More" : "1.302052",

META.yml  view on Meta::CPAN

  CGI::Snapp: '2.01'
  Capture::Tiny: '0.44'
  Carp: '1.2'
  Class::Load: '0.23'
  File::Spec: '3.4'
  HTTP::Exception: '0.04001'
  IO::Pipe: '1.15'
  Log::Handler: '0.88'
  Moo: '2.002004'
  Proc::Fork: '0.804'
  Try::Tiny: '0.27'
  lib: '0'
  parent: '0.234'
  strict: '0'
  warnings: '0'
resources:
  license: http://dev.perl.org/licenses/
  repository: https://github.com/ronsavage/CGI-Snapp-Dispatch.git
version: '2.00'
x_serialization_backend: 'CPAN::Meta::YAML version 0.012'

Makefile.PL  view on Meta::CPAN

		'Class::Load'		=> 0.23,
		'File::Spec'		=> 3.40,
		'HTTP::Exception'	=> 0.04001,
		'IO::Pipe'			=> 1.15,
		'lib'				=> 0,
		'Log::Handler'		=> 0.88,
		'Moo'				=> 2.002004,
		'parent'			=> 0.234,
		'Proc::Fork'		=> 0.804,
		'strict'			=> 0,
		'Try::Tiny'			=> 0.27,
		'warnings'			=> 0,
	},
	TEST_REQUIRES =>
	{
		'Test::Deep' => 0.120,
		'Test::More' => 1.302052,
		'Test::Pod' => 1.48,
	},
	VERSION_FROM => 'lib/CGI/Snapp/Dispatch.pm',
);

lib/CGI/Snapp/Dispatch.pm  view on Meta::CPAN

use CGI::PSGI;

use Class::Load ':all';

use HTTP::Exception;

use Log::Handler;

use Moo;

use Try::Tiny;

has logger =>
(
	is       => 'rw',
	default  => sub{return ''},
	required => 0,
);

has return_type =>
(

lib/CGI/Snapp/Dispatch.pm  view on Meta::CPAN

Unfortunately, this means that when $ENV{DOCUMENT_ROOT} is not set, File::Spec prepends a '/' to the file name.
So, an I<error_document> of '<x.html' becomes '/x.html'.

This module only prepends $ENV{DOCUMENT_ROOT} if it is not empty. Hence, with an empty $ENV{DOCUMENT_ROOT},
an I<error_document> of '<x.html' becomes 'x.html'.

See sub _parse_error_document() and t/args.t test_26().

=head3 Handling of exceptions

L<CGI::Application::Dispatch> uses a combination of eval and L<Try::Tiny>, together with L<Exception::Class>.
Likewise, L<CGI::Application::Dispatch::PSGI> uses the same combination, although without L<Exception::Class>.

CGI::Snapp::Dispatch just uses L<Try::Tiny>. This applies both to CGI scripts and PSGI scripts.
For L<CGI> scripts, errors are handled by sub _http_errror(). For L<PSGI|http://plackperl.org/> scripts, the code
throws errors of type L<HTTP::Exception>.

=head2 How does CGI::Snapp parse the path info?

Firstly, the path info is split on '/' chars. Hence /module_name/mode1 gives us ('', 'module_name', 'mode1').

The value 'module_name' is passed to L</translate_module_name($name)>. In this case, the result is 'Module::Name'.

You are free to override L</translate_module_name($name)> to customize it.

t/log.b.pl  view on Meta::CPAN

use lib 't/lib';
use strict;
use warnings;

use CGI::Snapp::Dispatch;

use Log::Handler;

use Test::More;

use Try::Tiny;

# ------------------------------------------------
# Check log from dispatch().

sub test_1
{
	my($logger) = Log::Handler -> new;

	$logger -> add
		(



( run in 0.293 second using v1.01-cache-2.11-cpan-05444aca049 )