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