Skip to content

Commit

Permalink
feat(http): 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 mangalaman93 committed May 17, 2023
1 parent 595b72d commit dcea048
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 @@ -244,6 +244,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{}).QueryNoGrpc(ctx, &req)
if err != nil {
Expand Down Expand Up @@ -273,7 +283,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 dcea048

Please sign in to comment.