You are on page 1of 6

Plack Middleware

in an onion skin

Starman

PERL5LIB=$PERL5LIB:./lib starman \ preload-app script/whitelabel.psgi

Middleware is like an onion


The HTTP request passes through each layer on the way in and the response does on the way out

Plack::Builder

builder { enable '+FX::Plack::Middleware::WhiteLabel'; $app; };

FX::Plack::Middleware::WhiteLabel

use parent 'Plack::Middleware';

call
sub call { my ( $self, $env ) = @_; # Extract the top level hostname from the full hostname my $host = $env->{HTTP_HOST}; $host =~ s/\..*$//; # Pass it in the X-site-domain $env->{ $self->build_req_header_key("X-site-domain") } = $host; return $self->app->($env); }

You might also like