MCPcopy
hub / github.com/dgraph-io/dgraph / write

Function write

graphql/admin/http.go:93–115  ·  view source on GitHub ↗

write chooses between the http response writer and gzip writer and sends the schema response using that.

(w http.ResponseWriter, rr *schema.Response, acceptGzip bool)

Source from the content-addressed store, hash-verified

91// write chooses between the http response writer and gzip writer
92// and sends the schema response using that.
93func write(w http.ResponseWriter, rr *schema.Response, acceptGzip bool) {
94 var out io.Writer = w
95
96 // set TouchedUids header
97 w.Header().Set(touchedUidsHeader, strconv.FormatUint(rr.GetExtensions().GetTouchedUids(), 10))
98
99 for key, val := range rr.Header {
100 w.Header()[key] = val
101 }
102
103 // If the receiver accepts gzip, then we would update the writer
104 // and send gzipped content instead.
105 if acceptGzip {
106 w.Header().Set("Content-Encoding", "gzip")
107 gzw := gzip.NewWriter(w)
108 defer gzw.Close()
109 out = gzw
110 }
111
112 if _, err := rr.WriteTo(out); err != nil {
113 glog.Error(err)
114 }
115}
116
117// WriteErrorResponse writes the error to the HTTP response writer in GraphQL format.
118func WriteErrorResponse(w http.ResponseWriter, r *http.Request, err error) {

Callers 4

startWritingMethod · 0.85
WriteErrorResponseFunction · 0.85
ServeHTTPMethod · 0.85
recoveryHandlerFunction · 0.85

Calls 6

GetTouchedUidsMethod · 0.80
GetExtensionsMethod · 0.80
WriteToMethod · 0.80
SetMethod · 0.65
CloseMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected