Created
February 6, 2014 21:00
-
-
Save Altreus/8852385 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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