Skip to content

Commit

Permalink
feat(rdf-response): Support RDF response via http query request (#8004)
Browse files Browse the repository at this point in the history
Add support for RDF format response for HTTP requests.

(cherry picked from commit 8324c68)
  • Loading branch information
ahsanbarkati authored and all-seeing-code committed Jan 30, 2023
1 parent c07f6fa commit 578bda4
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion dgraph/cmd/alpha/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,16 @@ func queryHandler(w http.ResponseWriter, r *http.Request) {
}
}

// If rdf is set true, then response will be in rdf format.
rdfResponse, err := parseBool(r, "rdf")
if err != nil {
x.SetStatus(w, x.ErrorInvalidRequest, err.Error())
return
}
if rdfResponse {
req.RespFormat = api.Request_RDF
}

// Core processing happens here.
resp, err := (&edgraph.Server{}).Query(ctx, &req)
if err != nil {
Expand Down Expand Up @@ -274,7 +284,11 @@ func queryHandler(w http.ResponseWriter, r *http.Request) {
x.Check2(out.Write(js))
}
x.Check2(out.WriteRune('{'))
writeEntry("data", resp.Json)
if rdfResponse {
writeEntry("data", resp.Rdf)
} else {
writeEntry("data", resp.Json)
}
x.Check2(out.WriteRune(','))
writeEntry("extensions", js)
x.Check2(out.WriteRune('}'))
Expand Down

0 comments on commit 578bda4

Please sign in to comment.