MCPcopy Create free account
hub / github.com/couchbase/cbft / ServeHTTP

Method ServeHTTP

rest_backup_restore.go:419–456  ·  view source on GitHub ↗
(
	w http.ResponseWriter, req *http.Request)

Source from the content-addressed store, hash-verified

417}
418
419func (h *BucketBackupIndexHandler) ServeHTTP(
420 w http.ResponseWriter, req *http.Request) {
421 bucketName := rest.BucketNameLookup(req)
422 if bucketName == "" {
423 rest.ShowError(w, req, "rest_backup_restore: bucket name is required",
424 http.StatusBadRequest)
425 return
426 }
427
428 queryParams := req.URL.Query()
429 var include bool
430 params := queryParams.Get("exclude")
431 if params == "" {
432 params = queryParams.Get("include")
433 include = true
434 }
435
436 _, scopeFilters, colFilters := parseBackupFilters(params, bucketName)
437
438 indexDefs, _, err := cbgt.CfgGetIndexDefs(h.mgr.Cfg())
439 if err != nil {
440 rest.ShowError(w, req, "could not retrieve index defs", http.StatusInternalServerError)
441 return
442 }
443
444 // filter index definitions for the given buckets/scopes/collections.
445 indexDefs = filterIndexDefinitions(indexDefs, nil,
446 scopeFilters, colFilters, include, true)
447
448 rv := struct {
449 Status string `json:"status"`
450 IndexDefs *cbgt.IndexDefs `json:"indexDefs"`
451 }{
452 Status: "ok",
453 IndexDefs: indexDefs,
454 }
455 rest.MustEncode(w, rv)
456}
457
458// parseBackupFilters parses the backup filters which would be
459// a comma seperated list of filters like,

Callers

nothing calls this directly

Calls 4

parseBackupFiltersFunction · 0.85
filterIndexDefinitionsFunction · 0.85
GetMethod · 0.80
QueryMethod · 0.45

Tested by

no test coverage detected