see other projects

Kelp framework

Plack-focused Perl web framework

Native solution for Plack/PSGI technology

Kelp is a light, modular, heavily Plack-centric web framework that focuses on getting things done.

It uses Plack as its foundation layer, and builds the web framework on top of it - most notable components of the framework are just extensions of the corresponding classes in Plack. This approach allows it to be lighter and cleaner than most of its competitors and make full use of the PSGI toolkit, including HTTP servers, standalone applications and middlewares. It is also extremely reliable in terms of runtime stability, backwards compatibility and the number (or lack) of bugs.

Kelp provides:

  • Advanced Routing. Create intricate, yet simple ways to capture HTTP requests and route them to their designated code. Use explicit and optional named placeholders, wildcards, or just regular expressions.
  • Flexible Configuration. Use different configuration file for each environment, e.g. development, deployment, etc. Merge a temporary configuration into your current one for testing and debugging purposes.
  • Enhanced Logging. Log messages at different levels of emergency. Log to a file, screen, or anything supported by Log::Dispatch.
  • Powerful Rendering. Use the built-in auto-rendering logic, or the template module of your choice to return rich text, html and JSON responses.
  • JSON encoder/decoder. Kelp comes with JSON, which will automatically choose the best (fastest, most secure) backend available (using JSON::MaybeXS).
  • Extendable Core. Kelp uses pluggable modules for everything. This allows anyone to add a module for a custom interface. Writing Kelp modules is easy.
  • Sleek Testing. Kelp takes Plack::Test and wraps it in an object oriented class of convenience methods. Testing is done via sending requests to your routes, then analyzing the response.

Example code

# lib/MyApp.pm
package MyApp;
use parent 'Kelp';

sub build {
        my $self = shift;
        my $r = $self->routes;
        $r->add( "/hello", sub { "Hello, world!" } );
        $r->add( '/hello/:name', 'greet' );
}

sub greet {
        my ( $self, $name ) = @_;
        "Hello, $name!";
}

1;

# app.psgi
use lib 'lib';
use MyApp;
my $app = MyApp->new;
$app->run;