('reply.time' => sub {
shift->respond_to(
html => {text => scalar localtime},
json => {json => {time => scalar localtime}},
);
});
$app->routes->get('/replytime')->to(cb => sub
that adds a
reply helper named "time" to the Mojolicious controller object. It will
respond to a JSON request with '{"time":"[scalar localtime]"}' and any other
request with a plain text response of