more minor refactoring, confirmed that the fix for the deploy warning works without leaking out of its scope
This commit is contained in:
parent
c4764314b3
commit
7cb1fe36bb
|
@ -12,7 +12,8 @@ use Data::UUID;
|
||||||
my $lastexpunge = 0;
|
my $lastexpunge = 0;
|
||||||
|
|
||||||
sub DeploySchema {
|
sub DeploySchema {
|
||||||
# TODO: figure out how to ensure schema is deployed without producing "table already exists" errors when it is already deployed
|
# we override sigwarn to prevent warnings from showing up when the schema has previously been deployed
|
||||||
|
# TODO: find a way to mute only the deploy warning here, should any other warnings somehow arise
|
||||||
local $SIG{__WARN__} = sub {};
|
local $SIG{__WARN__} = sub {};
|
||||||
eval { schema->deploy; };
|
eval { schema->deploy; };
|
||||||
}
|
}
|
||||||
|
@ -60,7 +61,7 @@ sub GetPaste {
|
||||||
]
|
]
|
||||||
]}) || undef;
|
]}) || undef;
|
||||||
}
|
}
|
||||||
sub SubmitPaste {
|
sub StorePaste {
|
||||||
my $params = shift;
|
my $params = shift;
|
||||||
my ($lang,$html) = PygmentsHighlight(lang => $params->{lang}, code => $params->{code});
|
my ($lang,$html) = PygmentsHighlight(lang => $params->{lang}, code => $params->{code});
|
||||||
#TODO: maybe figure out a nicer way of doing this, presently the UUID namespace changes with every app start
|
#TODO: maybe figure out a nicer way of doing this, presently the UUID namespace changes with every app start
|
||||||
|
@ -78,7 +79,7 @@ sub SubmitPaste {
|
||||||
|
|
||||||
# Startup
|
# Startup
|
||||||
DeploySchema();
|
DeploySchema();
|
||||||
warn "this is a warning!";
|
|
||||||
# Hooks
|
# Hooks
|
||||||
hook 'before' => sub { CheckExpiry(); };
|
hook 'before' => sub { CheckExpiry(); };
|
||||||
# Routes
|
# Routes
|
||||||
|
@ -91,7 +92,7 @@ get '/:id/raw' => sub { my $paste=GetPaste(scalar params 'route') or pass; con
|
||||||
post '/' => sub {
|
post '/' => sub {
|
||||||
my $p = params 'body';
|
my $p = params 'body';
|
||||||
ValidateParams($p) or return send_error('Submitted paste is not valid. Check your post title and language, and try again.', 400);
|
ValidateParams($p) or return send_error('Submitted paste is not valid. Check your post title and language, and try again.', 400);
|
||||||
my $id = SubmitPaste($p) or return redirect '/503.html';
|
my $id = StorePaste($p) or return redirect '/503.html';
|
||||||
return redirect "/$id";
|
return redirect "/$id";
|
||||||
};
|
};
|
||||||
#default
|
#default
|
||||||
|
|
Loading…
Reference in New Issue