forked from PerlDancer/Dancer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
TODO
64 lines (43 loc) · 1.47 KB
/
TODO
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
TODO
This is the roadmap of upcoming developments
* Reload route handlers when running in development environment
* Route caching support
When a path is firstly resolved through the route tree, we should
cache the result for future calls.
The path would be the cache key, the first route the value.
1 - GET / -> first call, so browse the route tree
2 - GET / -> second call, return cache('/');
* Conditions support for route matching:
get '/foo', {agent => 'Songbird (\d\.\d)[\d\/]*?'} => sub {
...
};
* Session support
We need a way to support web session in the easiest way possible.
Maybe something like that:
set session => true; # enable the session engine
get '/login' => sub {
template 'login'
};
post '/login' => sub {
my $user = User->authenticate(params->{login}, params->{password});
if ($user) {
session user_id => $user->id;
}
else {
var error => "Bad credentials";
pass;
}
};
Then the key 'user_id' should be accessible in other requests:
before => sub {
if (not session->{user_id}) {
var error => "Must be authenticated";
request->path_info('/error');
}
else {
var user => User->find(session->{user_id});
}
};
get '/home' => sub {
"Hello ".vars->{user}->name
};