The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Mojolicious::Plugin::ReplyTime - Reply with a simple response of just the current time

SYNOPSIS

  # Mojolicious
  $self->plugin('ReplyTime');

  # Mojolicious::Lite
  plugin 'ReplyTime';

  # Demo
  $ perl -Mojo -E 'plugin "ReplyTime"; app->start' routes
  /replytime  GET  replytime
  $ perl -Mojo -E 'plugin "ReplyTime"; app->start' get /replytime
  Sat Nov 30 17:45:57 2019

DESCRIPTION

Mojolicious::Plugin::ReplyTime is a Mojolicious plugin 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 just the localtime as a scalar.

Also included is a get route called /replytime that will call the reply->time helper.

Also included is a replytime command line utility which will launch a simple Mojolicious daemon that will respond to any request with the local time. The purpose for this is simply testing: rather than a static response in which you are unsure if the response is cached or not, reply time also responds with something fresh.

METHODS

Mojolicious::Plugin::ReplyTime inherits all methods from Mojolicious::Plugin and implements the following new ones.

register

  $plugin->register(Mojolicious->new);

Register plugin in Mojolicious application.

SEE ALSO

Mojolicious, Mojolicious::Guides, http://mojolicious.org.