File: endpoint.psgi

package info (click to toggle)
libatteanx-endpoint-perl 0.002-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 528 kB
  • sloc: javascript: 3,887; perl: 1,862; makefile: 12; sh: 5
file content (78 lines) | stat: -rwxr-xr-x 1,544 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/env perl

use strict;
use warnings;

use Data::Dumper;
use Plack::Request;
use Plack::Builder;
use Config::JFDI;
use Carp qw(confess);
use AtteanX::Endpoint;
use LWP::MediaTypes qw(add_type);

add_type( 'application/rdf+xml' => qw(rdf xrdf rdfx) );
add_type( 'text/turtle' => qw(ttl) );
add_type( 'text/plain' => qw(nt) );
add_type( 'text/x-nquads' => qw(nq) );
add_type( 'text/json' => qw(json) );
add_type( 'text/html' => qw(html xhtml htm) );

my $config;
if (my $file = $ENV{RDF_ENDPOINT_FILE}) {
	my $abs	= File::Spec->rel2abs( $file );
	$config	= {
		store	=> "Memory;$abs",
		endpoint	=> {
			service_description => {
				named_graphs	=> 1,
				default			=> 1,
			},
			html				=> {
				embed_images	=> 1,
				image_width		=> 200,
				resource_links	=> 1,
			},
			load_data	=> 0,
			update		=> 1,
        }
    };
} elsif ($config = eval { Config::JFDI->open( name => "AtteanX::Endpoint") }) {
} else {
	$config	= {
		store	=> "Memory",
		endpoint	=> {
			service_description => {
				named_graphs	=> 1,
				default			=> 1,
			},
			html				=> {
				embed_images	=> 1,
				image_width		=> 200,
				resource_links	=> 1,
			},
			load_data	=> 0,
			update		=> 1,
        }
    };
}

if (exists $ENV{'PERLRDF_STORE'}) {
	$config->{store} = $ENV{'PERLRDF_STORE'};
}

my $end		= AtteanX::Endpoint->new( $config );

my $app	= sub {
    my $env 	= shift;
    my $req 	= Plack::Request->new($env);
    my $resp	= $end->run( $req );
	return $resp->finalize;
};

builder {
	enable "AccessLog", format => "combined";
	$app;
};

__END__