Hello  !!

im new to dancer adn im really enjoying hwo easy and simple it is, im actuaally testing some examples on the cookbook and soms
simple functions and encountered a strange behaviour i cannot understand. Heres the code.


#!/usr/bin/env perl
use Dancer;
use MyApp01;

set port => 9001;

    before sub {

        if (! session('user') && request->path_info !~ m{^/login}) {
            redirect('/login');
        }
    };

    get '/login' => sub {
        # Display a login page; the original URL they requested is available as
        # vars->{requested_path}, so could be put in a hidden field in the form
        template 'login', { path => vars->{requested_path} };
    };

  post '/login' => sub {
        # Validate the username and password they supplied
        if (params->{username} eq 'bob' && params->{password} eq 'mierda') {
            session user => params->{user};
            redirect params->{path} || '/';
        } else {
            redirect '/login?failed=1';
        }
    };

  get '/logout' => sub {
     session->destroy;
     set_flash('You are logged out.');
     redirect '/login';
  };

  get '/' => sub {
        if (session('user')) {
            redirect('/login');
        } else {
                send_file '/o.html' ;
        }
  };

  get '/hello/:name/peter' => sub {
        return "Hi there " . params->{name};
  };


Allmos as posted on the dancer cookbook, login redirection works perfect, except when i request o.html, no matter if i
explicit test if the user is logged, the file is shown on the browser. Its a simple html form, and when i click on submit im
correctly redirected to /login but why is the first request not blocked ? Did i miss something on the manual about static files
and session management ?


Thank you
Javi