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

Function intFromQueryParam

dgraph/cmd/zero/http.go:29–43  ·  view source on GitHub ↗

intFromQueryParam checks for name as a query param, converts it to uint64 and returns it. It also writes any errors to w. A bool is returned to indicate if the param was parsed successfully.

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

Source from the content-addressed store, hash-verified

27// It also writes any errors to w. A bool is returned to indicate if the param was parsed
28// successfully.
29func intFromQueryParam(w http.ResponseWriter, r *http.Request, name string) (uint64, bool) {
30 str := r.URL.Query().Get(name)
31 if len(str) == 0 {
32 w.WriteHeader(http.StatusBadRequest)
33 x.SetStatus(w, x.ErrorInvalidRequest, fmt.Sprintf("%s not passed", name))
34 return 0, false
35 }
36 val, err := strconv.ParseUint(str, 0, 64)
37 if err != nil {
38 w.WriteHeader(http.StatusBadRequest)
39 x.SetStatus(w, x.ErrorInvalidRequest, fmt.Sprintf("Error while parsing %s", name))
40 return 0, false
41 }
42 return val, true
43}
44
45func (st *state) assign(w http.ResponseWriter, r *http.Request) {
46 x.AddCorsHeaders(w)

Callers 3

assignMethod · 0.85
removeNodeMethod · 0.85
moveTabletMethod · 0.85

Calls 4

SetStatusFunction · 0.92
GetMethod · 0.65
WriteHeaderMethod · 0.65
QueryMethod · 0.45

Tested by

no test coverage detected