Skip to content

Commit

Permalink
Merge pull request #28 from ternaustralia/edmond/sparql-describe
Browse files Browse the repository at this point in the history
Set default format when accept header includes multiple formats
  • Loading branch information
edmondchuc authored Jul 5, 2022
2 parents c206047 + dc8d654 commit 668a039
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/linkeddata_api/views/api_v1/resource/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ def get_resource():
repository_id = request.args.get("repository_id")
uri = request.args.get("uri")
format_ = request.headers.get("accept")
if not format_:
# TODO: Support 'format' query arg? It would make it easier to configure persistent redirect services.
# TODO: Curently we don't support multiple format types.
if not format_ or "," in format_:
format_ = "text/turtle"
include_incoming_relationships = request.args.get("include_incoming_relationships")
include_incoming_relationships = (
Expand All @@ -39,7 +41,8 @@ def get_resource():
) from err

graph = rdf.create_graph()
graph.parse(data=response.text)

graph.parse(data=response.text, format=format_)

if len(graph) == 0:
return "Resource not found", 404
Expand Down

0 comments on commit 668a039

Please sign in to comment.