Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can I change app_url of Perl Kelp App

I want to change app_url.

I did it as follows:

package Post;
use Kelp::Base 'Kelp';

use utf8;

sub before_dispatch {
    # overriding this method disables access logs
}

sub build {
    my $self = shift;
    
    $self->config_hash->{app_url}='https://perl-kelp.sys5.co';

It seems to work.
Is this a good way?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Changing the app_url in a Perl Kelp application as you described is valid but not ideal… A more standard approach involves using configuration files or environment variables. To use configuration files, create a file like conf/config.pl and specify your settings, including the app_url. For example:

{
    app_url => 'https://perl-kelp.sys5.co',
    # other configurations...
}

Then, modify your Post module to load this configuration:

package Post;
use Kelp::Base 'Kelp';

sub build {
    my $self = shift;
    my $app_url = $self->config('app_url');
    # use $app_url as needed
}

1;

Alternatively, you can use environment variables to manage configurations. Set an environment variable for app_url:

export APP_URL='https://perl-kelp.sys5.co'

Modify your Post module to read this variable:

package Post;
use Kelp::Base 'Kelp';

sub build {
    my $self = shift;
    my $app_url = $ENV{'APP_URL'} || 'default_value';
    # use $app_url as needed again
}

1;

Using configuration files or environment variables ensures better maintainability and flexibility for your Kelp application. All of this is generally considered a good practice for larger projects and organizations.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading