Skip to content

Instantly share code, notes, and snippets.

@Altreus
Created February 6, 2014 21:00
Show Gist options
  • Save Altreus/8852385 to your computer and use it in GitHub Desktop.
Save Altreus/8852385 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use strict;
use warnings;
use Web::Machine;
use Plack::App::Path::Router;
use Path::Router;
use Data::Dumper;
my $router = Path::Router->new();
$router->add_route(
':id?',
defaults => {
id => undef
},
target => Web::Machine->new( resource => 'Hackmachine::Resource' )->to_app
);
Plack::App::Path::Router->new( router => $router )->to_app;
package Hackmachine::Resource;
use strict;
use warnings;
use Data::Dumper;
use parent 'Web::Machine::Resource';
our @data = qw( hello hi hey howdy );
sub content_types_provided { [{ 'text/html' => 'to_html' }] }
sub init {
print "aaaa";
}
sub to_html {
q{<html>
<head>
<title>Hello World Resource</title>
</head>
<body>
<h1>Hello World</h1>
</body>
</html>}
}
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment