MCPcopy
hub / github.com/NVIDIA/aistore / listSortHandler

Function listSortHandler

dsort/handler.go:630–653  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

628}
629
630func listSortHandler(w http.ResponseWriter, r *http.Request) {
631 if !checkHTTPMethod(w, r, http.MethodGet) {
632 return
633 }
634
635 // Fetch regex
636 regexStr := r.URL.Query().Get(apc.QparamRegex)
637 var regex *regexp.Regexp
638 if regexStr != "" {
639 var err error
640 if regex, err = regexp.CompilePOSIX(regexStr); err != nil {
641 cmn.WriteErr(w, r, err)
642 return
643 }
644 }
645
646 body := cos.MustMarshal(Managers.List(regex))
647 if _, err := w.Write(body); err != nil {
648 glog.Error(err)
649 // When we fail write we cannot call InvalidHandler since it will be
650 // double header write.
651 return
652 }
653}
654
655// metricsHandler is the handler called for the HTTP endpoint /v1/sort/metrics.
656// A valid GET to this endpoint sends response with sort metrics.

Callers 1

SortHandlerFunction · 0.85

Calls 7

WriteErrFunction · 0.92
MustMarshalFunction · 0.92
ErrorFunction · 0.92
checkHTTPMethodFunction · 0.85
GetMethod · 0.65
ListMethod · 0.65
WriteMethod · 0.45

Tested by

no test coverage detected