Custom handlers

From EPrints Documentation
Revision as of 13:21, 12 August 2020 by (talk | contribs) (typos&formatting corrected)
Jump to: navigation, search

It has been more common to integrate EPrints with third-party applications such as Pure. In the past there has been two ways to incorporate custom handlers for such integration.

One method requires adding a Location block to the webserver configuration and a rewrite exception to the rewrite_exceptions configuration array. This has been seen to cause a race condition with mod_perl, in particular when integrating Pure's PDA handler.

The other option has been to hack perl_lib/EPrints/Apache/ to include a block of code for your custom handler. Since EPrints 3.4.2 specifying custom handlers is now possible as part of the EPrints configuration.

Below is the configuration you should use if you want to integrate Pure's PDA handler:

$c->{custom_handlers}->{pda}->{regex} = '^URLPATH/pda';
$c->{custom_handlers}->{pda}->{function} = sub
  my ( $r ) = @_;
  $r->handler( 'perl-script' );
  $r->set_handlers( PerlResponseHandler => [ 'PDA::PDAHandler' ] );
  return EPrints::Const::OK;

URLPATH is used as a macro for the path that the EPrints repository is hosted on. Typically this will be empty unless EPrints is run under some sub path (e.g. If you add custom handler configuration like this to your archive's cfg/cfg.d/ directory, there is no need to edit your webserver configuration, add a rewrite_exception to your configuration or hack perl_lib/EPrints/Apache/