Mercurial > hg > dbtune-rdf-services
changeset 27:d95e683fbd35 tip
Enable CORS on urispace redirects as well
author | Chris Cannam |
---|---|
date | Tue, 20 Feb 2018 14:52:02 +0000 |
parents | a93fe6c02d20 |
children | |
files | chord/urispace/urispace.pl classical/urispace/urispace.pl cmn/urispace/urispace.pl jamendo/urispace/urispace.pl magnatune/urispace/urispace.pl peel/urispace/urispace.pl |
diffstat | 6 files changed, 39 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/chord/urispace/urispace.pl Tue Feb 20 13:41:09 2018 +0000 +++ b/chord/urispace/urispace.pl Tue Feb 20 14:52:02 2018 +0000 @@ -1,19 +1,20 @@ :- module(urispace,[init/0]). - :- use_module(library('http/thread_httpd')). +:- use_module(library('http/http_cors')). :- use_module(library('semweb/rdf_db')). :- use_module(log). :- use_module(chord_parser). :- style_check(-discontiguous). +:- set_setting_default(http:cors, [*]). + + server(Port, Options) :- http_server(reply,[ port(Port),timeout(20)| Options]). - - namespace('http://dbtune.org/chord'). /** @@ -23,6 +24,7 @@ member(path(Path),Request), atom_concat(SymbolT,'.rdf',Path), atom_concat('/',Symbol,SymbolT), + cors_enable, !, (parse(Symbol,RDF) -> ( @@ -44,6 +46,7 @@ accept_png(AcceptHeader), !, atom_concat('/',Symbol,Path), + cors_enable, (parse(Symbol,RDF) -> ( member(rdf(_,'http://xmlns.com/foaf/0.1/depiction',Pic),RDF), @@ -66,6 +69,7 @@ namespace(NS), format(atom(Redirect),'~w~w.rdf',[NS,Path]), log:log('Sending a 303 towards ~w',Redirect), + cors_enable, throw(http_reply(see_other(Redirect),[])). accept_rdf('application/rdf+xml'). @@ -90,6 +94,7 @@ html(Html),namespace(Namespace), format(atom(Redirect),'~w~w~w',[Html,Namespace,Path]), log:log('Sending a 303 towards ~w',Redirect), + cors_enable, throw(http_reply(see_other(Redirect),[])). port(1111).
--- a/classical/urispace/urispace.pl Tue Feb 20 13:41:09 2018 +0000 +++ b/classical/urispace/urispace.pl Tue Feb 20 14:52:02 2018 +0000 @@ -1,17 +1,19 @@ :- module(urispace,[init/0]). - :- use_module(library('http/thread_httpd')). +:- use_module(library('http/http_cors')). :- use_module(library('semweb/rdf_db')). :- use_module(log). :- use_module(config). :- use_module(mapping). +:- set_setting_default(http:cors, [*]). + + server(Port, Options) :- http_server(reply,[ port(Port),timeout(20)| Options]). - /** * Closes the servlet */ @@ -37,6 +39,7 @@ !, concat_atom(RedirectP,Redirect), log:log('Sending a 303 towards ~w',Redirect), + cors_enable, throw(http_reply(see_other(Redirect),[])). accept_rdf('application/rdf+xml'). @@ -58,6 +61,7 @@ !, concat_atom(RedirectP,Redirect), log:log('Sending a 303 towards ~w',Redirect), + cors_enable, throw(http_reply(see_other(Redirect),[])). init :-
--- a/cmn/urispace/urispace.pl Tue Feb 20 13:41:09 2018 +0000 +++ b/cmn/urispace/urispace.pl Tue Feb 20 14:52:02 2018 +0000 @@ -1,12 +1,15 @@ :- module(urispace,[init/0]). - :- use_module(library('http/thread_httpd')). +:- use_module(library('http/http_cors')). :- use_module(library('semweb/rdf_db')). :- use_module(log). :- use_module(config). :- use_module(mapping). +:- set_setting_default(http:cors, [*]). + + server(Port, Options) :- http_server(reply,[ port(Port),timeout(20)| Options]). @@ -37,6 +40,7 @@ !, concat_atom(RedirectP,Redirect), log:log('Sending a 303 towards ~w',Redirect), + cors_enable, throw(http_reply(see_other(Redirect),[])). accept_rdf('application/rdf+xml'). @@ -58,6 +62,7 @@ !, concat_atom(RedirectP,Redirect), log:log('Sending a 303 towards ~w',Redirect), + cors_enable, throw(http_reply(see_other(Redirect),[])). init :-
--- a/jamendo/urispace/urispace.pl Tue Feb 20 13:41:09 2018 +0000 +++ b/jamendo/urispace/urispace.pl Tue Feb 20 14:52:02 2018 +0000 @@ -1,17 +1,18 @@ :- module(urispace,[init/0]). - :- use_module(library('http/thread_httpd')). +:- use_module(library('http/http_cors')). :- use_module(library('semweb/rdf_db')). :- use_module(log). :- use_module(config). :- use_module(mapping). +:- set_setting_default(http:cors, [*]). + + server(Port, Options) :- http_server(reply,[ port(Port),timeout(20)| Options]). - - /** * Closes the servlet */ @@ -36,7 +37,8 @@ mapping:see_other_rdf(requested_pattern(Pattern),redirect_pattern(RedirectP)), !, concat_atom(RedirectP,Redirect), - log:log('Sending a 303 towards ~w',Redirect), + log:log('Sending a 303 towards ~w',Redirect), + cors_enable, throw(http_reply(see_other(Redirect),[])). accept_rdf('application/rdf+xml'). @@ -58,6 +60,7 @@ !, concat_atom(RedirectP,Redirect), log:log('Sending a 303 towards ~w',Redirect), + cors_enable, throw(http_reply(see_other(Redirect),[])). init :-
--- a/magnatune/urispace/urispace.pl Tue Feb 20 13:41:09 2018 +0000 +++ b/magnatune/urispace/urispace.pl Tue Feb 20 14:52:02 2018 +0000 @@ -1,12 +1,15 @@ :- module(urispace,[init/0]). - :- use_module(library('http/thread_httpd')). +:- use_module(library('http/http_cors')). :- use_module(library('semweb/rdf_db')). :- use_module(log). :- use_module(config). :- use_module(mapping). +:- set_setting_default(http:cors, [*]). + + server(Port, Options) :- http_server(reply,[ port(Port),timeout(20)| Options]). @@ -37,6 +40,7 @@ !, concat_atom(RedirectP,Redirect), log:log('Sending a 303 towards ~w',Redirect), + cors_enable, throw(http_reply(see_other(Redirect),[])). accept_rdf('application/rdf+xml'). @@ -58,6 +62,7 @@ !, concat_atom(RedirectP,Redirect), log:log('Sending a 303 towards ~w',Redirect), + cors_enable, throw(http_reply(see_other(Redirect),[])). init :-
--- a/peel/urispace/urispace.pl Tue Feb 20 13:41:09 2018 +0000 +++ b/peel/urispace/urispace.pl Tue Feb 20 14:52:02 2018 +0000 @@ -1,17 +1,19 @@ :- module(urispace,[init/0]). - :- use_module(library('http/thread_httpd')). +:- use_module(library('http/http_cors')). :- use_module(library('semweb/rdf_db')). :- use_module(log). :- use_module(config). :- use_module(mapping). +:- set_setting_default(http:cors, [*]). + + server(Port, Options) :- http_server(reply,[ port(Port),timeout(20)| Options]). - /** * Closes the servlet */ @@ -37,6 +39,7 @@ !, concat_atom(RedirectP,Redirect), log:log('Sending a 303 towards ~w',Redirect), + cors_enable, throw(http_reply(see_other(Redirect),[])). accept_rdf('application/rdf+xml'). @@ -58,6 +61,7 @@ !, concat_atom(RedirectP,Redirect), log:log('Sending a 303 towards ~w',Redirect), + cors_enable, throw(http_reply(see_other(Redirect),[])). init :-