Questions tagged [mojolicious]

Mojolicious is an MVC web framework in Perl.

Back in the early days of the web there was this wonderful Perl library called CGI, many people only learned because of it. It was simple enough to get started without knowing much about the language and powerful enough to keep you going, learning by doing was much fun. While most of the techniques used are outdated now, the idea behind it is not. Mojolicious is a new attempt at implementing this idea using state of the art technology.

Features An amazing web framework supporting a simplified single file mode through Mojolicious::Lite. Powerful out of the box with RESTful routes, plugins, Perl-ish templates, session management, signed cookies, testing framework, static file server, I18N, first class unicode support and much more for you to discover.

Features

  • An amazing MVC web framework supporting a simplified single file mode through Mojolicious::Lite. Powerful out of the box with RESTful routes, plugins, Perl-ish templates, session management, signed cookies, testing framework, static file server, I18N, first class unicode support and much more for you to discover.
  • Very clean, portable and Object Oriented pure Perl API without any hidden magic and no requirements besides Perl 5.8.7.

  • Full stack HTTP 1.1 and WebSocket client/server implementation with IPv6, TLS, Bonjour, IDNA, Comet (long polling), chunking and multipart support.

  • Builtin async IO web server supporting epoll, kqueue, UNIX domain sockets and hot deployment, perfect for embedding.

  • Automatic CGI, FastCGI and PSGI detection.

  • JSON and XML/HTML5 parser with CSS3 selector support.

  • Fresh code based upon years of experience developing Catalyst.

Resources and links

672 questions
5
votes
4 answers

Perl Mojolicious - How to make it handle multiple connections at once?

I setup a quick Mojolicious server like this: use Mojolicious::Lite; get '/' => sub { my $self = shift; sleep 5; #sleep here, I'm testing multiple connections at once $self->render_text('Hello World!'); }; app->start; I then start…
jonathanpeppers
  • 26,115
  • 21
  • 99
  • 182
5
votes
1 answer

How to verify the name of a file?

I have a function that returns a file for the user avatar and I want to create tests for it. What I want to do is to check the name of the file. This is the function: sub get_avatar { my $self = shift; my $username =…
Marinescu
  • 429
  • 3
  • 18
5
votes
2 answers

Using Mojo::UserAgent and accessing the JSON in response?

How can I get access to JSON in a mojo response? $txn = $ua->post( $url, $headers, json => {json} ) What's the way to get the JSON response from the txn?
Evan Carroll
  • 78,363
  • 46
  • 261
  • 468
5
votes
1 answer

What is the correct way to use Mojo::Log?

I would like to use Mojolicious' Mojo::Log tool to do logging in my Mojolicious web application. However, I am unsure of the proper/correct way to use it. The documentation shows it used directly from the script, but fails to say if it's thread-safe…
Daniel Gray
  • 1,697
  • 1
  • 21
  • 41
5
votes
1 answer

Mojolicious(hypnotoad) - enforce TLS v1.2

How to enforce Mojolicious(hypnotoad) app to use TLS v1.2? mojo version output: CORE Perl (v5.16.3, linux) Mojolicious (8.0, Supervillain) OPTIONAL Cpanel::JSON::XS 4.04+ (n/a) EV 4.0+ (4.22) IO::Socket::Socks…
Sachin Dangol
  • 504
  • 5
  • 13
5
votes
1 answer

Need help with routing in Mojolicious

I have the "Pages" controller with the "show" method and "Auths" controller with the "check" method which returns 1 if user is authenticated. I have "default" page ("/profile"). I need to redirect to / if the user is authenticated and redirect all…
VeroLom
  • 3,856
  • 9
  • 34
  • 48
5
votes
1 answer

Mojolicious re-using a previously established connection

I'm trying to reuse a previously established websocket connection to avoid the websocket handshake. I found that a custom websocket transaction can be built using build_websocket_tx (more details here), and there's a connection identifier for every…
Apoorv Joshi
  • 389
  • 3
  • 15
5
votes
1 answer

How to find route name for given path in Mojolicious?

When I parse html response body I want to find route names for all links found in the body. I use next code snippet: my $url = Mojo::URL->new( $got ); my $method = uc( $url->query->clone->param( '_method' ) || 'GET' ); my $c = …
Eugen Konkov
  • 22,193
  • 17
  • 108
  • 158
5
votes
2 answers

How to use route name while testing mojolicious application?

I have read Test::Mojo but do not find how to use route name while application testing: $t->get_ok( 'list_users' )->status_is( 302 )->location_is( 'auth_login' ); Where list_users and auth_login are: $r->get( '/login' )->to( 'auth#login' )->name(…
Eugen Konkov
  • 22,193
  • 17
  • 108
  • 158
5
votes
1 answer

serve static directory from mojolicious other than /public

I have looked at a variety of places to find the best way to serve a directory of static files from within a mojolicious app and this is as close as I've been able to get: package ExampleServer; use Mojo::Base 'Mojolicious'; use…
chicks
  • 2,393
  • 3
  • 24
  • 40
5
votes
2 answers

How to create common handler for all incoming URLs?

I'm in process of writing some web api, which returns data in JSON format. For all incoming urls i need to return some result from cache if cache period doesnt expire. This logic is universal for all URLs. Question: How to implement some common…
drvtiny
  • 705
  • 3
  • 13
5
votes
1 answer

How should I process HTML META tags with Mojo::UserAgent?

I have to play with some misconfigured web servers, so I started processing the HTML meta tags to feed information back into the web user-agent object. I tried a variety of ways of doing this in Mojolicious and settled on a looking for a "finish"…
brian d foy
  • 129,424
  • 31
  • 207
  • 592
5
votes
1 answer

How to troubleshoot Hypnotoad worker failures

I've got an app that is served up by Hypnotoad, with no reverse proxy.It has 15 workers, with 2 clients allowed apiece. The app is launched via hypnotoad in foreground mode. I am seeing the following in the log/production.log: [Wed Apr 1 16:28:12…
arafeandur
  • 196
  • 1
  • 5
5
votes
1 answer

Mojolicious dynamic route action depending on state

I am using Mojolicious::Plugin::Authentication to handle authentication in my app. I am trying to set up a route for slash '/' that will have one controller/action if authenticated, and another if not (i.e., you go to a different page depending on…
Franz Kafka
  • 780
  • 2
  • 13
  • 34
5
votes
3 answers

Configure URLs with prefix in Mojolicious behind Reverse Proxy (ProxyPass)

I'm looking for a reliable way to configure Mojolicious running behind an Apache reverse proxy under /app, so that url_for('/foo') actually returns /app/foo instead of just /foo (otherwise all the links would be broken). The documentation shows a…
basic6
  • 3,643
  • 3
  • 42
  • 47