File: Links.pm

package info (click to toggle)
libminion-perl 9.09%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,016 kB
  • sloc: perl: 1,097; makefile: 9
file content (26 lines) | stat: -rw-r--r-- 542 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package LinkCheck::Controller::Links;
use Mojo::Base 'Mojolicious::Controller';

sub check {
  my $self = shift;

  my $v = $self->validation;
  $v->required('url');
  return $self->render(action => 'index') if $v->has_error;

  my $id = $self->minion->enqueue(check_links => [$v->param('url')]);
  $self->redirect_to('result', id => $id);
}

sub index { }

sub result {
  my $self = shift;

  return $self->reply->not_found
    unless my $job = $self->minion->job($self->param('id'));

  $self->render(result => $job->info->{result});
}

1;