Custom handlers

From EPrints Documentation
Revision as of 19:18, 23 July 2020 by Drn@ecs.soton.ac.uk (talk | contribs) (Add page about custom handlers)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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 addoing a Location block to the webserver configuration and a rewrite exception to the the rewrite_exceptions configuration array. This has been seen to cause a race condition with mod_perl, in particular when intergating Pure's PDA handler.

The other option has been to hack perl_lib/EPrints/Apache/Rewrite.pm 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 PDS 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. http://eprints.example.org/some_path/). If you custom handler configuration like this, there is no need to edit your webserver configuration, add a rewrite_exception to your configuration or hack perl_lib/EPrints/Apache/Rewrite.pm'.