-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConfig.pm
104 lines (95 loc) · 3.05 KB
/
Config.pm
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
=pod
Главный Конфиг сервиса
=cut
{
'Проект'=>'Тест плугинов',
# установка лог файла раньше установки режима, поэтому всегда log/development.log!!!!
#mojo_mode=>$ENV{PLACK_ENV} ? 'production' : 'development', # production $ENV{ MOJO_MODE}
mojo_mode=> 'development',
# mode принудительно production если увидит $ENV{PLACK_ENV}
mojo_log_level => 'debug',#$ENV{PLACK_ENV} ? 'error' : 'debug',
mojo_plugins=>[ # map $self->plugin($_)
[charset => { charset => 'UTF-8' }, ],
['EDumper', helper =>'dumper'],
['RoutesAuthDBI',
dbh=>sub{ shift->dbh->{'main'}},
auth=>{current_user_fn=>'auth_user'},
#~ access=> { },
admin=>{prefix=>'myadmin', trust=>'фубар'},
template => {schema => 'test3', },#tables=>{profiles=>'профили'},
],
],
mojo_session => {cookie_name => 'ELK'},
# Хуки
#~ mojo_hooks=>{
#~ before_dispatch => sub {1;},
#~ },
# Хазы
#~ mojo_has => {
#~ foo=>sub {my $app = shift; },
#~ },
mojo_secrets => ['true 123 test-app',],
#!!! пустой has dbh=>sub{{};}; в app !!!
dbh=>{# dsn, user, passwd
'main'=>{
connect=>["DBI:Pg:dbname=test;", "guest", undef, {# DBI->connect
ShowErrorStatement => 1,
AutoCommit => 1,
RaiseError => 1,
PrintError => 0,
pg_enable_utf8 => 1,
#mysql_enable_utf8 => 1,
#mysql_auto_reconnect=>1,
#~ AutoInactiveDestroy => 1,
}],
do=>['set datestyle to "ISO, DMY";',],
sth=>{# prepared sth
'table.columns'=><<SQL,
select *
from information_schema.columns
where
table_catalog='test'
and table_schema=? --'public'
and table_name=? --'routes'
;
SQL
},
}
},
#!!! пустой has sth=>sub{{};}; в app !!!
sth => { main=>{},},# prepared sth
#~ now=>"select now();"
namespaces => ['Test'],
routes => [
[
route=>'/callback',
over=>{access=>{auth=>1, role=>'admin'}},
to=>sub {shift->render(format=>'txt', text=>'You have access!')},
name=>'foo',#'install#manual', namespace000=>'Mojolicious::Plugin::RoutesAuthDBI',
],[
route=>'/check-auth',
over=>{access=>sub {my ($user, $route, $c, $captures, $args) = @_; return $user;}},
to=>{cb=>sub {my $c =shift; $c->render(format=>'txt', text=>"Hi @{[$c->auth_user->{login}]}! You have access!");}},
],[
route=>'/routes',
to=>{cb=>sub {my $c =shift; $c->render(format=>'txt', text=>$c->dumper($c->match->endpoint));}},
name=>'app routes',
],[
route=>'/man',
over=>{access=>{auth=>0,}},
to=>['install#manual', namespace=>'Mojolicious::Plugin::RoutesAuthDBI',],#
],[
route=>'/schema/:schema',
over=>{access=>{auth=>0,}},
to=>['db#schema', namespace=>'Mojolicious::Plugin::RoutesAuthDBI',],#
],[
route=>'/test1',
over=>{access=>{auth=>1,}},
to=>'test1#test1',
],[
route=>'/test1/:action',
over=>{access=>{auth=>1,}},
to=>{controller=>'Test1'},
],
],
};