PUT/DELETE config: a single user function
()
| 65 | |
| 66 | // PUT/DELETE config: a single user function |
| 67 | func (h *handler) handlePutDbConfigFunction() error { |
| 68 | functionName := h.PathVar("function") |
| 69 | if h.rq.Method != "DELETE" { |
| 70 | // PUT: |
| 71 | var functionConfig *functions.FunctionConfig |
| 72 | if err := h.readJSONInto(&functionConfig); err != nil { |
| 73 | return err |
| 74 | } |
| 75 | return h.mutateDbConfig(func(dbConfig *DbConfig) error { |
| 76 | if dbConfig.UserFunctions == nil { |
| 77 | dbConfig.UserFunctions = &functions.FunctionsConfig{} |
| 78 | } |
| 79 | dbConfig.UserFunctions.Definitions[functionName] = functionConfig |
| 80 | return nil |
| 81 | }) |
| 82 | } else { |
| 83 | // DELETE: |
| 84 | return h.mutateDbConfig(func(dbConfig *DbConfig) error { |
| 85 | if dbConfig.UserFunctions == nil || dbConfig.UserFunctions.Definitions[functionName] == nil { |
| 86 | return base.HTTPErrorf(http.StatusNotFound, "") |
| 87 | } |
| 88 | delete(dbConfig.UserFunctions.Definitions, functionName) |
| 89 | return nil |
| 90 | }) |
| 91 | } |
| 92 | } |
nothing calls this directly
no test coverage detected