EditPlugin 修改插件信息
(httpResponse http.ResponseWriter, httpRequest *http.Request)
| 132 | |
| 133 | //EditPlugin 修改插件信息 |
| 134 | func EditPlugin(httpResponse http.ResponseWriter, httpRequest *http.Request) { |
| 135 | |
| 136 | pluginPriority := httpRequest.PostFormValue("pluginPriority") |
| 137 | pluginName := httpRequest.PostFormValue("pluginName") |
| 138 | pluginConfig := httpRequest.PostFormValue("pluginConfig") |
| 139 | |
| 140 | pluginDesc := httpRequest.PostFormValue("pluginDesc") |
| 141 | isStop := httpRequest.PostFormValue("isStop") |
| 142 | pluginType := httpRequest.PostFormValue("pluginType") |
| 143 | version := httpRequest.PostFormValue("version") |
| 144 | |
| 145 | index, err := strconv.Atoi(pluginPriority) |
| 146 | if err != nil { |
| 147 | controller.WriteError(httpResponse, "210001", "plugin", "[ERROR]Illegal pluginPriority!", err) |
| 148 | return |
| 149 | } |
| 150 | pStop, err := strconv.Atoi(isStop) |
| 151 | if err != nil { |
| 152 | controller.WriteError(httpResponse, "210005", "plugin", "[ERROR]Illegal isStop!", err) |
| 153 | return |
| 154 | } |
| 155 | pType, err := strconv.Atoi(pluginType) |
| 156 | if err != nil { |
| 157 | controller.WriteError(httpResponse, "210009", "plugin", "[ERROR]Illegal pluginType!", err) |
| 158 | return |
| 159 | } |
| 160 | |
| 161 | flag, err := plugin_config.CheckConfig(pluginName, []byte(pluginConfig)) |
| 162 | if !flag { |
| 163 | controller.WriteError(httpResponse, "500000", "plugin", "[ERROR]插件配置无效:"+err.Error(), err) |
| 164 | return |
| 165 | } |
| 166 | exits, err := plugin.CheckIndexIsExist(pluginName, index) |
| 167 | if exits { |
| 168 | controller.WriteError(httpResponse, "210003", "plugin", "[ERROR]Plugin priority is existed!", err) |
| 169 | return |
| 170 | } |
| 171 | flag, err = plugin.CheckNameIsExist(pluginName) |
| 172 | if !flag { |
| 173 | controller.WriteError(httpResponse, "210004", "plugin", "[ERROR]Plugin name does not exist!", err) |
| 174 | return |
| 175 | } |
| 176 | flag, result, err := plugin.EditPlugin(pluginName, pluginConfig, pluginDesc, version, index, pStop, pType) |
| 177 | if !flag { |
| 178 | controller.WriteError(httpResponse, "210000", "plugin", result, err) |
| 179 | return |
| 180 | } |
| 181 | |
| 182 | controller.WriteResultInfo(httpResponse, "plugin", "", nil) |
| 183 | } |
| 184 | |
| 185 | //DeletePlugin 删除插件信息 |
| 186 | func DeletePlugin(httpResponse http.ResponseWriter, httpRequest *http.Request) { |
nothing calls this directly
no test coverage detected