MCPcopy Index your code
hub / github.com/dgraph-io/dgraph / commonHandler

Function commonHandler

dgraph/cmd/alpha/http.go:44–59  ·  view source on GitHub ↗

Common functionality for these request handlers. Returns true if the request is completely handled here and nothing further needs to be done.

(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

42// Common functionality for these request handlers. Returns true if the request is completely
43// handled here and nothing further needs to be done.
44func commonHandler(w http.ResponseWriter, r *http.Request) bool {
45 // Do these requests really need CORS headers? Doesn't seem like it, but they are probably
46 // harmless aside from the extra size they add to each response.
47 x.AddCorsHeaders(w)
48 w.Header().Set("Content-Type", "application/json")
49
50 if r.Method == "OPTIONS" {
51 return true
52 } else if !allowed(r.Method) {
53 w.WriteHeader(http.StatusBadRequest)
54 x.SetStatus(w, x.ErrorInvalidMethod, "Invalid method")
55 return true
56 }
57
58 return false
59}
60
61// Read request body, transparently decompressing if necessary. Return nil on error.
62func readRequest(w http.ResponseWriter, r *http.Request) []byte {

Callers 6

loginHandlerFunction · 0.85
queryHandlerFunction · 0.85
mutationHandlerFunction · 0.85
commitHandlerFunction · 0.85
alterHandlerFunction · 0.85
adminSchemaHandlerFunction · 0.85

Calls 5

AddCorsHeadersFunction · 0.92
SetStatusFunction · 0.92
allowedFunction · 0.85
SetMethod · 0.65
WriteHeaderMethod · 0.65

Tested by

no test coverage detected