diff options
Diffstat (limited to 'lib/jitterbug/WebService.pm')
-rw-r--r-- | lib/jitterbug/WebService.pm | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/jitterbug/WebService.pm b/lib/jitterbug/WebService.pm new file mode 100644 index 0000000..4f89be8 --- /dev/null +++ b/lib/jitterbug/WebService.pm @@ -0,0 +1,34 @@ +package jitterbug::WebService; + +BEGIN { + use Dancer ':syntax'; + load_plugin 'jitterbug::Plugin::Redis'; +} + +use File::Spec; + +set serializer => 'JSON'; + +get '/build/:project/:commit/:version' => sub { + my $project = params->{project}; + my $commit = params->{commit}; + my $version = params->{version}; + + my $conf = setting 'jitterbug'; + + my $file = File::Spec->catfile( $conf->{reports}->{dir}, + $project, $commit, $version . '.txt' ); + + if ( -f $file ) { + open my $fh, '<', $file; + my @content = <$fh>; + close $fh; + { + commit => $commit, + version => $version, + content => join( '', @content ), + }; + } +}; + +1; |