Created
February 8, 2014 10:19
-
-
Save Altreus/8881519 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::HyperMachine; | |
my $app = Web::HyperMachine->new(); | |
$app->with('Hackmachine::Resource'); | |
$app->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 parent 'Web::HyperMachine::Resource'; | |
__PACKAGE__->uri('hack'); | |
__PACKAGE__->related('Hackmachine::OtherResource'); | |
our @data = qw( hello hi hey howdy ); | |
sub content_types_provided { [{ 'text/html' => 'to_html' }] } | |
sub fetch { | |
my ($self, $id) = @_; | |
return $data[$id]; | |
} | |
sub to_html { | |
my $self = shift; | |
my $resource = $self->{resource}; | |
q{<h1>} . $resource . q{ world</h1>} | |
} | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment