File: linked_data.psgi

package info (click to toggle)
librdf-linkeddata-perl 1.940-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 400 kB
  • sloc: perl: 1,929; makefile: 12; sh: 1
file content (79 lines) | stat: -rw-r--r-- 1,733 bytes parent folder | download | duplicates (4)
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
79
#!/usr/bin/env perl

use strict;
use warnings;
use Plack::App::RDF::LinkedData;
use RDF::LinkedData;
use Plack::Request;
use Plack::Builder;
use Config::ZOMG;
use Carp qw(confess);
use Module::Load::Conditional qw[can_load];

=head1 NAME

linked_data.psgi - A simple Plack server for RDF as linked data

=head1 INSTRUCTIONS

See L<Plack::App::RDF::LinkedData> for instructions on how to use this.

=cut



my $config;
BEGIN {
	unless ($config = Config::ZOMG->open(
                                        name => "RDF::LinkedData"
                                       )) {
		if ($ENV{'PERLRDF_STORE'}) {
			$config->{store} = $ENV{'PERLRDF_STORE'};
			$config->{base_uri} = 'http://localhost:5000';
		} else {
			confess "Couldn't find config";
		}
	}
}

if ($ENV{'LOG_ADAPTER'}) {
  use Log::Any::Adapter;
  Log::Any::Adapter->set($ENV{'LOG_ADAPTER'});
}


my $linkeddata = Plack::App::RDF::LinkedData->new();

$linkeddata->configure($config);

my $rdf_linkeddata = $linkeddata->to_app;

builder {
	enable "Head";
	enable "ContentLength";
	enable "ConditionalGET";
	if (defined($config->{expires}) && (can_load( modules => { 'Plack::Middleware::Expires' => 0 }))) {
		enable 'Expires',
		  content_type => qr//,
		  expires => $config->{expires}
	  };
	if (can_load( modules => { 'Plack::Middleware::CrossOrigin' => 0 })) { enable 'CrossOrigin' => %{$config->{cors}}};
	$rdf_linkeddata;
};


__END__


=head1 AUTHOR

Kjetil Kjernsmo C<< <kjetilk@cpan.org> >>

=head1 COPYRIGHT

Copyright (c) 2010 ABC Startsiden AS and Gregory Todd Williams and
2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Kjetil Kjernsmo. This program is
free software; you can redistribute it and/or modify it under the same
terms as Perl itself.

=cut