Mercurial > hg > dbtune-rdf-services
comparison jamendo/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 | df9685986338 |
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 | |
13 | |
14 | 15 |
15 /** | 16 /** |
16 * Closes the servlet | 17 * Closes the servlet |
17 */ | 18 */ |
18 reply(Request) :- | 19 reply(Request) :- |
34 concat_atom(PatternX,'/',Path), | 35 concat_atom(PatternX,'/',Path), |
35 delete(PatternX,'',Pattern), | 36 delete(PatternX,'',Pattern), |
36 mapping:see_other_rdf(requested_pattern(Pattern),redirect_pattern(RedirectP)), | 37 mapping:see_other_rdf(requested_pattern(Pattern),redirect_pattern(RedirectP)), |
37 !, | 38 !, |
38 concat_atom(RedirectP,Redirect), | 39 concat_atom(RedirectP,Redirect), |
39 log:log('Sending a 303 towards ~w',Redirect), | 40 log:log('Sending a 303 towards ~w',Redirect), |
41 cors_enable, | |
40 throw(http_reply(see_other(Redirect),[])). | 42 throw(http_reply(see_other(Redirect),[])). |
41 | 43 |
42 accept_rdf('application/rdf+xml'). | 44 accept_rdf('application/rdf+xml'). |
43 %accept_rdf('text/xml'). | 45 %accept_rdf('text/xml'). |
44 accept_rdf(AcceptHeader) :- | 46 accept_rdf(AcceptHeader) :- |
56 delete(PatternX,'',Pattern), | 58 delete(PatternX,'',Pattern), |
57 mapping:see_other(requested_pattern(Pattern),redirect_pattern(RedirectP)), | 59 mapping:see_other(requested_pattern(Pattern),redirect_pattern(RedirectP)), |
58 !, | 60 !, |
59 concat_atom(RedirectP,Redirect), | 61 concat_atom(RedirectP,Redirect), |
60 log:log('Sending a 303 towards ~w',Redirect), | 62 log:log('Sending a 303 towards ~w',Redirect), |
63 cors_enable, | |
61 throw(http_reply(see_other(Redirect),[])). | 64 throw(http_reply(see_other(Redirect),[])). |
62 | 65 |
63 init :- | 66 init :- |
64 config:port(P), | 67 config:port(P), |
65 server(P,[]), | 68 server(P,[]), |