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

Mojo::Manual::FAQ - Frequently Asked Questions

QUESTIONS

Do i have to use Mojo::Base?

Absolutely not, you could just use any other accessor generator in your modules, Mojo::Base is just a base class and will stay out of your way.

Do i have to use Mojo::Template?

Not at all, it is just a convenient default option and can be replaced with any other template engine out there.

Why do my programs break if i use content instead of body?

The content attribute of Mojo::Message has to contain a special Mojo::Content object which offers advanced HTTP body manipulation functions. The body method is a wrapper around that and what you will want to use in most cases.

    $tx->res->body('Hello World!');

If you want to send a file for example, then content would be the right choice.

    my $file = Mojo::File->new;
    $file->path('/etc/passwd');
    $tx->res->content->file($file);