NAME

Mojolicious::Plugin::PgURLHelper - Mojolicious Plugin

SYNOPSIS

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

  # Mojolicious::Lite
  plugin 'PgURLHelper';

  # Use the helper
  my $pg_url = $self->pg_url({host => 'localhost', database => 'foo', user => 'bar', pwd => 'baz'});
  my $pg = Mojo::Pg->new($pg_url);
  $self->plugin('Minion', {Pg => $pg_url});

DESCRIPTION

Mojolicious::Plugin::PgURLHelper is a Mojolicious plugin to easily create PostgreSQL URLs suitable for Mojo::Pg or Minion::Backend::Pg.

HELPERS

pg_url

  my $pg_url = $self->pg_url({host => 'localhost', database => 'foo', user => 'bar', pwd => 'baz'});

Arguments:

host : string, PostgreSQL host, MANDATORY
database : string, name of the database, MANDATORY
port : integer, PostgreSQL port, optional, no default
user : string, username for the connection, can't contain a colon (:), optional, no default
pwd : string, password for the connection, optional, no default

Returns a connection string suitable for Mojo::Pg or Minion::Backend::Pg on success.

Returns undef on failure. The reason of the failure is printed in Mojolicious log, severity: error.

Note that if you specify a user, you must specify a password, and vice versa.

METHODS

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

register

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

Register plugin in Mojolicious application.

BUGS and SUPPORT

The latest source code can be browsed and fetched at:

  https://framagit.org/luc/mojolicious-plugin-pgurlhelper
  git clone https://framagit.org/luc/mojolicious-plugin-pgurlhelper.git

Bugs and feature requests will be tracked at:

  https://framagit.org/luc/mojolicious-plugin-pgurlhelper/issues

AUTHOR

  Luc DIDRY
  CPAN ID: LDIDRY
  ldidry@cpan.org
  https://fiat-tux.fr/

COPYRIGHT

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.

SEE ALSO

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