comparison cmn/urispace/urispace.pl @ 27:d95e683fbd35 tip

Enable CORS on urispace redirects as well
author Chris Cannam
date Tue, 20 Feb 2018 14:52:02 +0000
parents 9e70cd92f14e
children
comparison
equal deleted inserted replaced
26:a93fe6c02d20 27:d95e683fbd35
1 :- module(urispace,[init/0]). 1 :- module(urispace,[init/0]).
2 2
3
4 :- use_module(library('http/thread_httpd')). 3 :- use_module(library('http/thread_httpd')).
4 :- use_module(library('http/http_cors')).
5 :- use_module(library('semweb/rdf_db')). 5 :- use_module(library('semweb/rdf_db')).
6 :- use_module(log). 6 :- use_module(log).
7 :- use_module(config). 7 :- use_module(config).
8 :- use_module(mapping). 8 :- use_module(mapping).
9 9
10 :- set_setting_default(http:cors, [*]).
11
12
10 server(Port, Options) :- 13 server(Port, Options) :-
11 http_server(reply,[ port(Port),timeout(20)| Options]). 14 http_server(reply,[ port(Port),timeout(20)| Options]).
12 15
13 16
14 17
35 delete(PatternX,'',Pattern), 38 delete(PatternX,'',Pattern),
36 mapping:see_other_rdf(requested_pattern(Pattern),redirect_pattern(RedirectP)), 39 mapping:see_other_rdf(requested_pattern(Pattern),redirect_pattern(RedirectP)),
37 !, 40 !,
38 concat_atom(RedirectP,Redirect), 41 concat_atom(RedirectP,Redirect),
39 log:log('Sending a 303 towards ~w',Redirect), 42 log:log('Sending a 303 towards ~w',Redirect),
43 cors_enable,
40 throw(http_reply(see_other(Redirect),[])). 44 throw(http_reply(see_other(Redirect),[])).
41 45
42 accept_rdf('application/rdf+xml'). 46 accept_rdf('application/rdf+xml').
43 %accept_rdf('text/xml'). 47 %accept_rdf('text/xml').
44 accept_rdf(AcceptHeader) :- 48 accept_rdf(AcceptHeader) :-
56 delete(PatternX,'',Pattern), 60 delete(PatternX,'',Pattern),
57 mapping:see_other(requested_pattern(Pattern),redirect_pattern(RedirectP)), 61 mapping:see_other(requested_pattern(Pattern),redirect_pattern(RedirectP)),
58 !, 62 !,
59 concat_atom(RedirectP,Redirect), 63 concat_atom(RedirectP,Redirect),
60 log:log('Sending a 303 towards ~w',Redirect), 64 log:log('Sending a 303 towards ~w',Redirect),
65 cors_enable,
61 throw(http_reply(see_other(Redirect),[])). 66 throw(http_reply(see_other(Redirect),[])).
62 67
63 init :- 68 init :-
64 config:port(P), 69 config:port(P),
65 server(P,[]), 70 server(P,[]),