Skip to content

Instantly share code, notes, and snippets.

@Altreus
Created February 8, 2014 10:19
Show Gist options
  • Save Altreus/8881519 to your computer and use it in GitHub Desktop.
Save Altreus/8881519 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use strict;
use warnings;
use Web::HyperMachine;
my $app = Web::HyperMachine->new();
$app->with('Hackmachine::Resource');
$app->to_app;
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