diff --git a/lemonldap-ng-common/lib/Lemonldap/NG/Common/PSGI.pm b/lemonldap-ng-common/lib/Lemonldap/NG/Common/PSGI.pm index d71f7c1fe..997cd14ed 100644 --- a/lemonldap-ng-common/lib/Lemonldap/NG/Common/PSGI.pm +++ b/lemonldap-ng-common/lib/Lemonldap/NG/Common/PSGI.pm @@ -149,7 +149,7 @@ sub init { return 1; } -sub router { _mustBeDefined(@_) } +sub handler { _mustBeDefined(@_) } sub sendHtml { my ( $self, $req, $template ) = @_; @@ -217,7 +217,7 @@ sub run { sub _run { my $self = shift; return sub { - $self->router( Lemonldap::NG::Common::PSGI::Request->new( $_[0] ) ); + $self->handler( Lemonldap::NG::Common::PSGI::Request->new( $_[0] ) ); }; } @@ -251,7 +251,7 @@ Use Lemonldap::NG::Common::PSGI::Router for REST API. return 1; } - sub router { + sub handler { my ( $self, $req ) = @_; # Do something and return a PSGI response # NB: $req is a Lemonldap::NG::Common::PSGI::Request object diff --git a/lemonldap-ng-common/lib/Lemonldap/NG/Common/PSGI/Request.pm b/lemonldap-ng-common/lib/Lemonldap/NG/Common/PSGI/Request.pm index 673bfd6ef..cdfb513c6 100644 --- a/lemonldap-ng-common/lib/Lemonldap/NG/Common/PSGI/Request.pm +++ b/lemonldap-ng-common/lib/Lemonldap/NG/Common/PSGI/Request.pm @@ -164,7 +164,7 @@ PSGIs # See Lemonldap::NG::Common::PSGI ... - sub router { + sub handler { my ( $self, $req ) = @_; # Do something and return a PSGI response # NB: $req is a Lemonldap::NG::Common::PSGI::Request object diff --git a/lemonldap-ng-common/lib/Lemonldap/NG/Common/PSGI/Router.pm b/lemonldap-ng-common/lib/Lemonldap/NG/Common/PSGI/Router.pm index df82916f2..0bccbb47d 100644 --- a/lemonldap-ng-common/lib/Lemonldap/NG/Common/PSGI/Router.pm +++ b/lemonldap-ng-common/lib/Lemonldap/NG/Common/PSGI/Router.pm @@ -77,7 +77,7 @@ sub genRoute { } } -sub routerAbort { +sub handlerAbort { my ( $self, $path, $msg ) = @_; delete $self->routes->{$path}; $self->addRoute( @@ -90,7 +90,7 @@ sub routerAbort { # Methods that dispatch requests -sub router { +sub handler { my ( $self, $req ) = @_; #print STDERR Dumper($self->routes);use Data::Dumper; diff --git a/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Nginx.pm b/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Nginx.pm index bf31f1440..471f27315 100644 --- a/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Nginx.pm +++ b/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Nginx.pm @@ -34,7 +34,7 @@ sub _run { }; } -## @method PSGI-Response router() +## @method PSGI-Response handler() # Transform headers returned by handler main process: # each "Name: value" is transformed to: # - Headername: Name @@ -55,7 +55,7 @@ sub _run { # auth_request_set $llremoteuser $upstream_http_lm_remote_user # #@param $req Lemonldap::NG::Common::PSGI::Request -sub router { +sub handler { my ( $self, $req ) = @_; my $hdrs = $req->{respHeaders}; $req->{respHeaders} = {}; diff --git a/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/PSGI.pm b/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/PSGI.pm index 04fde5411..1c74c8b0b 100644 --- a/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/PSGI.pm +++ b/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/PSGI.pm @@ -38,7 +38,7 @@ Lemonldap::NG::Handler::PSGI - Base library for protected PSGI applications. return 1; } - sub router { + sub handler { my ( $self, $req ) = @_; # Will be called only if authorisated diff --git a/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/PSGI/Base.pm b/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/PSGI/Base.pm index fba2de40e..eeaba5ade 100644 --- a/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/PSGI/Base.pm +++ b/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/PSGI/Base.pm @@ -33,7 +33,7 @@ sub init { ## @methodi void _run() # Check if protecton is activated then return a code ref that will launch -# _authAndTrace() if protection in on or router() else +# _authAndTrace() if protection in on or handler() else #@return code-ref sub _run { my $self = shift; @@ -63,7 +63,7 @@ sub _run { # Handle unprotected requests return sub { my $req = Lemonldap::NG::Common::PSGI::Request->new( $_[0] ); - my $res = $self->router($req); + my $res = $self->handler($req); push @{ $res->[1] }, %{ $req->{respHeaders} }; return $res; }; @@ -71,7 +71,7 @@ sub _run { } ## @method private PSGI-Response _authAndTrace($req) -# Launch Lemonldap::NG::Handler::SharedConf::run() and then router() if +# Launch Lemonldap::NG::Handler::SharedConf::run() and then handler() if # response is 200. sub _authAndTrace { my ( $self, $req ) = @_; @@ -80,8 +80,8 @@ sub _authAndTrace { $req->userData($datas) if ($datas); if ( $res < 300 ) { - $self->lmLog( 'User authenticated, calling router()', 'debug' ); - return $self->router($req); + $self->lmLog( 'User authenticated, calling handler()', 'debug' ); + return $self->handler($req); } else { my %h = $req->{respHeaders} ? %{ $req->{respHeaders} } : (); diff --git a/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/PSGI/Server.pm b/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/PSGI/Server.pm index dde3cbdfb..1c53db2e3 100644 --- a/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/PSGI/Server.pm +++ b/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/PSGI/Server.pm @@ -8,7 +8,7 @@ extends 'Lemonldap::NG::Handler::PSGI'; ## @method void _run() # Return subroutine that add headers stored in $req->{respHeaders} in -# response returned by router() +# response returned by handler() # sub _run { my ($self) = @_; @@ -20,12 +20,12 @@ sub _run { }; } -## @method PSGI-Response router($req) +## @method PSGI-Response handler($req) # If PSGI is used as an authentication FastCGI only, this method will be # called for authenticated users and returns only 200. Headers are set by # Lemonldap::NG::Handler::PSGI. # @param $req Lemonldap::NG::Common::PSGI::Request -sub router { +sub handler { return [ 200, [ 'Content-Length', 0 ], [] ]; } diff --git a/lemonldap-ng-handler/t/60-Lemonldap-NG-Handler-PSGI.t b/lemonldap-ng-handler/t/60-Lemonldap-NG-Handler-PSGI.t index fc3a17c1d..585708a0a 100644 --- a/lemonldap-ng-handler/t/60-Lemonldap-NG-Handler-PSGI.t +++ b/lemonldap-ng-handler/t/60-Lemonldap-NG-Handler-PSGI.t @@ -77,7 +77,7 @@ count(2); done_testing( count() ); -sub Lemonldap::NG::Handler::PSGI::router { +sub Lemonldap::NG::Handler::PSGI::handler { my ( $self, $req ) = @_; ok( $req->{HTTP_AUTH_USER} eq 'dwho', 'Header is given to app' ) or explain( $req->{HTTP_REMOTE_USER}, 'dwho' ); diff --git a/lemonldap-ng-manager/KINEMATIC.md b/lemonldap-ng-manager/KINEMATIC.md index 8d9e1b5c8..1057f1145 100644 --- a/lemonldap-ng-manager/KINEMATIC.md +++ b/lemonldap-ng-manager/KINEMATIC.md @@ -23,7 +23,7 @@ PSGI system launch the previous sub sub | - +-> Common::PSGI::Router::router ( Lemonldap::NG::Common::PSGI::Request->new() ) + +-> Common::PSGI::Router::handler ( Lemonldap::NG::Common::PSGI::Request->new() ) | +-> Common::PSGI::Router::followPath() | diff --git a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Notifications.pm b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Notifications.pm index c033a464d..8463450fd 100644 --- a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Notifications.pm +++ b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Notifications.pm @@ -87,7 +87,7 @@ sub notifAccess { # TODO: old parameters (with table) unless ( $self->{notificationStorage} ) { - $self->routerAbort( notifications => + $self->handlerAbort( notifications => 'notificationStorage is not defined in configuration' ); return 0; } @@ -102,7 +102,7 @@ sub notifAccess { # If type not File or DBI, abort unless ( $args->{type} =~ /^(File|DBI|LDAP)$/ ) { - $self->routerAbort( notifications => + $self->handlerAbort( notifications => "Only File, DBI or LDAP supported for Notifications" ); return 0; } @@ -112,7 +112,7 @@ sub notifAccess { unless ( $self->_notifAccess( Lemonldap::NG::Common::Notification->new($args) ) ) { - $self->routerAbort( + $self->handlerAbort( notifications => $Lemonldap::NG::Common::Notification::msg ); return 0; }