Bailador is route-based web development framework trying to imitate the Perl Dancer framework which in turn started as a clone of the Ruby Sinatra project. The Perl 6 Maven site runs on it.

Note! This site is about Perl 6.
If you are looking for a solution for the current production version of Perl 5, please check out the Perl 5 tutorial.


Fixed routes

get '/' => sub {
    return 'Home';

get '/about' => sub {
    return 'About';

Route with placeholder

get '/hello/:name' => sub ($name) {
    "Hello $name!"

Regex routes

get /id\-(.+)/ => sub ($x) {
    return "I got $x";

Junction routes

get any('/h', '/help', '/halp') => sub {
    return 'Help in many ways';

Supported HTTP methods

  • get
  • post
  • put
  • delete

GET parameters

The request keyword rpresents the request object. It has a method called params that returns a hash containing the parameters passed in a GET request.

/echo?text=blabla handled by

get '/echo' => sub {
    return 'echo via GET: ' ~ (request.params<text> // '');

POST parameters

Templating systems



The request keyword returns the request object. The params method returns a hash of the parameters recived via GET and POST methods. As Dancer2 also mixes GET and POST params and overwrites the GET params by the POST params, the same happens in Bailador, though this might change in the future.

  • params
  • port
  • request_uri
  • uri
  • path
  • method
  • is_get
  • is_post
  • is_put
  • is_delete
  • is_head
  • is_patch
  • content_type
  • content_length
  • body


The content_type function sets the content-type of the response.

The header function sets the header of the response.

The status function sets the status code of the response.



  • Separate GET and POST parameters
  • Add Hooks
  • Sessions
  • Logging
  • Configurtion

The Perl 6 Tricks and Treats newsletter has been around for a while. If you are interested to get special notification when there is new content on this site, it is the best way to keep track:
Full name:
This is a newsletter temporarily running on my personal site ( using Mailman, till I implement an alternative system in Perl 6.
Gabor Szabo
Written by Gabor Szabo

Published on 2015-01-12


In the comments, please wrap your code snippets within <pre> </pre> tags and use spaces for indentation.
comments powered by Disqus
Suggest a change
Elapsed time: 3.91533466

Perl 6 Tricks and Treats newsletter

Register to the free newsletter now, and get updates and news.