package CMTD::Main; use strict; use warnings; use utf8; use Mojo::Base 'Mojolicious::Controller'; sub index { my ($self) = @_; $self->render(text => 'Go away!'); } sub captcha { } sub c_list { } sub c_add { my ($self) = @_; my $ref = $self->referrer; unless ($ref and ref($ref) eq 'HASH') { $self->res->code(400); $self->render(text => "can't detect referred page"); return; } my $site = $self->app->sites->{ $ref->{site} }; unless ($site and ref($site) eq 'HASH') { $self->res->code(400); $self->render(text => "no such site"); return; } eval { 1; } or do { chomp $@; my $msg = sprintf "Error when listing comments for %s/%s: %s", $ref->{site}, $ref->{pid}, $@; $self->app->log->error($msg); $self->res->code(500); $self->render(text => 'internal error'); }; } 1;