@@ -62,6 +62,8 @@ pub async fn run_httpd<T: ToSocketAddrs>(
62
62
. service ( coffee_show)
63
63
. service ( coffee_search)
64
64
. service ( coffee_list_plugins_in_remote)
65
+ . service ( coffee_disable)
66
+ . service ( coffee_enable)
65
67
. with_json_spec_at ( "/api/v1" )
66
68
. build ( )
67
69
} )
@@ -198,6 +200,34 @@ async fn coffee_search(
198
200
handle_httpd_response ! ( result)
199
201
}
200
202
203
+ #[ api_v2_operation]
204
+ #[ post( "/disable" ) ]
205
+ async fn coffee_disable (
206
+ data : web:: Data < AppState > ,
207
+ body : Json < Disable > ,
208
+ ) -> Result < HttpResponse , Error > {
209
+ let plugin = & body. plugin ;
210
+
211
+ let mut coffee = data. coffee . lock ( ) . await ;
212
+ let result = coffee. disable ( plugin) . await ;
213
+
214
+ handle_httpd_response ! ( result, "Plugin '{plugin}' disabled successfully" )
215
+ }
216
+
217
+ #[ api_v2_operation]
218
+ #[ post( "/enable" ) ]
219
+ async fn coffee_enable (
220
+ data : web:: Data < AppState > ,
221
+ body : Json < Enable > ,
222
+ ) -> Result < HttpResponse , Error > {
223
+ let plugin = & body. plugin ;
224
+
225
+ let mut coffee = data. coffee . lock ( ) . await ;
226
+ let result = coffee. enable ( plugin) . await ;
227
+
228
+ handle_httpd_response ! ( result, "Plugin '{plugin}' enabled successfully" )
229
+ }
230
+
201
231
// this is just a hack to support swagger UI with https://paperclip-rs.github.io/paperclip/
202
232
// and the raw html is taken from https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/installation.md#unpkg
203
233
#[ get( "/" ) ]
0 commit comments