MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / handleCreateTarget

Method handleCreateTarget

rest/api.go:540–547  ·  view source on GitHub ↗

Stub handler for hadling create DB on the public API returns HTTP status 412 if the db exists, and 403 if it doesn't. fixes issue #562

()

Source from the content-addressed store, hash-verified

538// if the db exists, and 403 if it doesn't.
539// fixes issue #562
540func (h *handler) handleCreateTarget() error {
541 dbname := h.PathVar("targetdb")
542 if _, err := h.server.GetDatabase(h.ctx(), dbname); err != nil {
543 return base.HTTPErrorf(http.StatusForbidden, "Creating a DB over the public API is unsupported")
544 } else {
545 return base.HTTPErrorf(http.StatusPreconditionFailed, "Database already exists")
546 }
547}
548
549func (h *handler) handleEFC() error { // Handles _ensure_full_commit.
550 // no-op. CouchDB's replicator sends this, so don't barf. Status must be 201.

Callers

nothing calls this directly

Calls 4

PathVarMethod · 0.95
ctxMethod · 0.95
HTTPErrorfFunction · 0.92
GetDatabaseMethod · 0.45

Tested by

no test coverage detected