| 1 | 1 | ▶ | use Plack::Builder; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 2 | 1 | ▶ | use Plack::App::DAIA::Validator; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | |||
| 4 | { | ||
| 5 | # This dummy DAIA server always returns a document if queried for | ||
| 6 | # an identifier that consists of a alphanumerical chars and ':' | ||
| 7 | package MyDAIAServer; | ||
| 8 | 1 | ▶ | use parent 'Plack::App::DAIA'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | 1 | ▶ | no warnings 'redefine'; # because this is loaded multiple times |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | |||
| 12 | 1 | ▶ | sub init { |
|
Subroutine
init: called CC=1 SCAR=0.0
Subroutine
init: called CC=1 SCAR=0.0
Subroutine
init: called CC=1 SCAR=0.0
Subroutine
init: called CC=1 SCAR=0.0
| |||
| 13 | 1 | $_[0]->idformat(qr{^[a-z0-9:]+$}i); | |
| 14 | 1 | $_[0]->xslt(1); | |
| 15 | } | ||
| 16 | |||
| 17 | 1 | ▶ | sub retrieve { |
|
Subroutine
retrieve: called CC=1 SCAR=0.0
Subroutine
retrieve: called CC=1 SCAR=0.0
Subroutine
retrieve: called CC=1 SCAR=0.0
Subroutine
retrieve: called CC=1 SCAR=0.0
| |||
| 18 | 1 | my ($self, $id) = @_; | |
| 19 | 1 | my $daia = DAIA::Response->new(); | |
| 20 | |||
| 21 | 1 | eval { $daia->document( id => $id ); }; | |
| 22 | 1 | $daia->addMessage( en => "You asked for $id" ); | |
| 23 | |||
| 24 | 1 | return $daia; | |
| 25 | }; | ||
| 26 | } | ||
| 27 | |||
| 28 | # Run the DAIA server at '/' and a validator at '/validator' | ||
| 29 | |||
| 30 | 1 | ▶ | builder { |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 31 | 1 | mount '/validator' => Plack::App::DAIA::Validator->new(); | |
| 32 | 1 | mount '/' => MyDAIAServer->new->to_app; | |
| 33 | 1 | }; | |
| 34 | |||
| 35 | __END__ | ||