Assist with Mojolicious web framework development using documentation search, browsing, and testing requests without starting a server.
Use the Mojolicious app script for efficient development and testing.
Use WebSearch with site restriction to search Mojolicious documentation:
WebSearch: "routing guide site:docs.mojolicious.org"
WebSearch: "websocket site:docs.mojolicious.org"
Or use WebFetch with Google Custom Search:
https://www.google.com/cse?cx=014527573091551588235:pwfplkjpgbi&q=<query>
Documentation URLs follow these patterns:
Mojolicious modules: https://docs.mojolicious.org/Mojolicious/Guides/Routing
/ separators for Mojolicious namespaceMojolicious::Guides::Routing → /Mojolicious/Guides/RoutingCPAN modules: https://docs.mojolicious.org/Path::To::Module
:: separators for other modulesMojo::UserAgent → /Mojo::UserAgentQuick testing is useful for rapid manual verification during development.
Use the app script for GET requests only. For other HTTP methods (POST, PUT, DELETE), use curl with a running server:
# GET request (use app.pl)
./app.pl get /api/users
# GET request with query parameters (use app.pl)
./app.pl get /api/users?page=1
# GET request with custom headers (use app.pl)
./app.pl get /api/users -H 'Authorization: Bearer token123'
# For POST, PUT, DELETE: Start server first
./app.pl daemon -l http://127.0.0.1:3000
# POST request with JSON data (use curl)
curl -X POST http://127.0.0.1:3000/api/users \
-H 'Content-Type: application/json' \
-d '{"name":"Alice","email":"alice@example.com"}'
# PUT request (use curl)
curl -X PUT http://127.0.0.1:3000/api/users/1 \
-H 'Content-Type: application/json' \
-d '{"name":"Alice Updated"}'
# DELETE request (use curl)
curl -X DELETE http://127.0.0.1:3000/api/users/1
# curl with custom headers
curl http://127.0.0.1:3000/api/users \
-H 'Authorization: Bearer token123'
List all application routes:
./app.pl routes
This shows the routing table with HTTP methods, paths, and route names.
For proper automated testing, use Test::Mojo. It provides a comprehensive testing framework with chainable assertions.
Create test files in the t/ directory:
# t/api.t
use Test2::V0;
use Test::Mojo;
# Create test instance
my $t = Test::Mojo->new('path/to/app.pl');
# Test GET request
$t->get_ok('/api/todos')
->status_is(200)
->json_is([]);
# Test POST request
$t->post_ok('/api/todos' => json => {title => 'Buy milk', completed => 0})
->status_is(201)
->json_has('/id')
->json_is('/title' => 'Buy milk')
->json_is('/completed' => 0);
# Test GET specific todo
$t->get_ok('/api/todos/1')
->status_is(200)
->json_is('/title' => 'Buy milk');
# Test PUT request
$t->put_ok('/api/todos/1' => json => {completed => 1})
->status_is(200)
->json_is('/completed' => 1);
# Test DELETE request
$t->delete_ok('/api/todos/1')
->status_is(200)
->json_has('/message');
# Test error cases
$t->get_ok('/api/todos/999')
->status_is(404)
->json_has('/error');
$t->post_ok('/api/todos' => json => {})
->status_is(400)
->json_is('/error' => 'Title is required');
done_testing();
# Run all tests
prove -lv t/
# Run specific test file
prove -lv t/api.t
# Run with verbose output
perl t/api.t
get_ok, post_ok, put_ok, delete_ok, etc.status_is(), status_isnt()json_is(), json_has(), json_like()content_like(), content_type_is()header_is(), header_like()# View all routes in your application
./app.pl routes
# Test a GET endpoint (use app.pl)
./app.pl get /api/users
# Test with authentication header (use app.pl)
./app.pl get /api/protected -H 'Authorization: Bearer mytoken'
# Start server for testing POST/PUT/DELETE
./app.pl daemon -l http://127.0.0.1:3000
# Test a POST endpoint with JSON (use curl)
curl -X POST http://127.0.0.1:3000/api/users \
-H 'Content-Type: application/json' \
-d '{"name":"Bob","role":"admin"}'
./app.pl routest/ directory./app.pl get for GET requests, or curl with daemon for other methodsprove -lv t/ to verify all functionality./app.pl routes to understand the current routing structuret/ directory for reliable, repeatable testing./app.pl get <path> (no server needed)./app.pl daemon and use curlsite:docs.mojolicious.org <query>https://docs.mojolicious.org/Mojolicious/Pathhttps://docs.mojolicious.org/Module::Name