AnyEvent-HTTPD-Router

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

            $httpd->stop_request;
            $req->respond([
                200, 'ok', { 'Content-Type' => 'text/plain', }, "test!" ]);
        },
        $all_methods => '/my-method' => sub {
            my ( $httpd, $req ) = @_;
            $httpd->stop_request;
            $req->respond([
                200, 'ok', { 'X-Your-Method' => $req->method }, '' ]);
        },
        GET => '/calendar/:year/:month/:day' => sub {
            my ( $httpd, $req, $param ) = @_;
            my $calendar_entries = get_cal_entries(
                $param->{year}, $param->{month}, $param->{day}
            );

            $httpd->stop_request;
            $reg->respond([
                200, 'ok', { 'Content-Type' => 'application/json'},
                to_json($calendar_entries)
            ]);
        },
        GET => '/static-files/*' => sub {
            my ( $httpd, $req, $param ) = @_;
            my $requeted_file = $param->{'*'};
            my ($content, $content_type) = black_magic($requested_file);

            $httpd->stop_request;
            $req->respond([
                200, 'ok', { 'Content-Type' => $content_type }, $content ]);

lib/AnyEvent/HTTPD/Router.pm  view on Meta::CPAN

         $httpd->stop_request;
         $req->respond([
             200, 'ok', { 'Content-Type' => 'text/plain', }, "test!" ]);
     },
     $all_methods => '/my-method' => sub {
         my ( $httpd, $req ) = @_;
         $httpd->stop_request;
         $req->respond([
             200, 'ok', { 'X-Your-Method' => $req->method }, '' ]);
     },
     GET => '/calendar/:year/:month/:day' => sub {
         my ( $httpd, $req, $param ) = @_;
         my $calendar_entries = get_cal_entries(
             $param->{year}, $param->{month}, $param->{day}
         );

         $httpd->stop_request;
         $reg->respond([
             200, 'ok', { 'Content-Type' => 'application/json'},
             to_json($calendar_entries)
         ]);
     },
     GET => '/static-files/*' => sub {
         my ( $httpd, $req, $param ) = @_;
         my $requeted_file = $param->{'*'};
         my ($content, $content_type) = black_magic($requested_file);

         $httpd->stop_request;
         $req->respond([
             200, 'ok', { 'Content-Type' => $content_type }, $content ]);



( run in 0.358 second using v1.01-cache-2.11-cpan-5dc5da66d9d )