1. Fabrice Gabolde
  2. Floop

Overview

HTTPS SSH

README

What's Floop?

Floop used to be an experiment with p5-mop-redux, the new MOP for Perl 5 inspired by the syntax proposed for Perl 6. After that project floundered, Floop was ported to Moo, losing a couple features in the process but gaining in production viability.

Floop is a small PSGI-aware Web route framework that currently includes:

  • Dancer-style simple route matching with named path parts, e.g. /foo/:bar

  • Catalyst-style route chaining (basic)

  • a pluggable logging subsystem

  • generally high modularity, allowing you to mix and match existing Floop components in your app (not that anybody has written any)

How do I use Floop?

Unlike Dancer/Dancer 2, which use singletons/package variables heavily, and Catalyst, which defines app components as classes, Floop apps (and components, which behave much the same in almost all ways) are object instances. To define a Floop app, instantiate the Floop class and start calling methods on it. The method you're probably looking for is add_route. add_route takes a route object as a parameter and installs it in the application's dispatcher, which will then take care of calling the route handler whenever the route's pattern is matched. Like this:

my $app = Floop->new(...);
my $route = Floop::Route->new(
    pattern => '/foo/:bar',
    handler => sub { 'I am called whenever a request is made to /foo/*' });
$app->add_route($route);

Future versions of Floop will include more comfortable/reusable ways to define components.