Returns the current database config object for this request
()
| 16 | |
| 17 | // Returns the current database config object for this request |
| 18 | func (h *handler) getDBConfig() (config *DbConfig, etagVersion string, err error) { |
| 19 | h.assertAdminOnly() |
| 20 | if h.server.BootstrapContext.Connection == nil { |
| 21 | if dbConfig := h.server.GetDatabaseConfig(h.db.Name); dbConfig != nil { |
| 22 | etagVersion = dbConfig.Version |
| 23 | if etagVersion == "" { |
| 24 | etagVersion = "0-" |
| 25 | } |
| 26 | return &dbConfig.DbConfig, etagVersion, nil |
| 27 | } |
| 28 | return nil, "", nil |
| 29 | } else if found, databaseConfig, err := h.server.fetchDatabase(h.ctx(), h.db.Name); err != nil { |
| 30 | return nil, "", err |
| 31 | } else if !found { |
| 32 | return nil, "", base.HTTPErrorf(http.StatusNotFound, "database config not found") |
| 33 | } else { |
| 34 | return &databaseConfig.DbConfig, databaseConfig.Version, nil |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | // Updates the database config via a callback function that can modify a `DbConfig` |
| 39 | func (h *handler) mutateDbConfig(mutator func(*DbConfig) error) error { |
no test coverage detected