I ended up combining what edem said with some stuff that I did and this is my end result:
sub begin :Private {
my ($self, $c) = @_;
#don't allow trailing slashes!
my @path = split "/", $c->req->path, -1;
if(@path and (pop @path eq '')) {
my $p = join '/', @path;
#set as moved permanently
$c->res->redirect("/$p", 301);
return;
}
}
If there is a trailing slash at the end of the request, it will always redirect to the same url but without the slash.