From 8b4f51f65700f9e8baa8a8e755e8826a4af20980 Mon Sep 17 00:00:00 2001 From: aszlig Date: Mon, 27 Apr 2015 04:55:13 +0200 Subject: [PATCH] Channel.pm: Actually deliver channel expressions. So this is the final part which is needed in order to be able to deliver custom channels, everything else is now just polishing. We do this by simply redirecting to the build product download URL and we use binary_cache_url the same way as in NixChannel.pm. Signed-off-by: aszlig --- src/lib/Hydra/Controller/Channel.pm | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/lib/Hydra/Controller/Channel.pm b/src/lib/Hydra/Controller/Channel.pm index 033fc4de..902d6019 100644 --- a/src/lib/Hydra/Controller/Channel.pm +++ b/src/lib/Hydra/Controller/Channel.pm @@ -54,4 +54,30 @@ sub overview : Chained('channel') PathPart('') Args(0) { } +sub nixexprs : Chained('channel') PathPart('') Args(1) { + my ($self, $c, $productName) = @_; + + my $product = $c->stash->{lastSuccessful}->buildproducts->find( + { type => "channel", name => $productName } + ); + + my $url = $c->uri_for( + $c->controller("Build")->action_for("download"), + [$c->stash->{lastSuccessful}->id], + $product->productnr, + $productName + ); + + $c->res->redirect($url); +} + + +sub binary_cache_url : Chained('channel') PathPart('binary-cache-url') Args(0) { + my ($self, $c) = @_; + $c->stash->{'plain'} = { data => $c->uri_for('/') }; + $c->response->content_type('text/plain'); + $c->forward('Hydra::View::Plain'); +} + + 1;