mirror of
https://github.com/semaphoreui/semaphore.git
synced 2025-01-20 15:29:28 +01:00
feat(runners): unregister endpoint
This commit is contained in:
parent
7a1e08023e
commit
60d759872a
@ -91,6 +91,7 @@ func Route() *mux.Router {
|
||||
routersAPI.Use(StoreMiddleware, JSONMiddleware, runners.RunnerMiddleware)
|
||||
routersAPI.Path("/runners/{runner_id}").HandlerFunc(runners.GetRunner).Methods("GET", "HEAD")
|
||||
routersAPI.Path("/runners/{runner_id}").HandlerFunc(runners.UpdateRunner).Methods("PUT")
|
||||
routersAPI.Path("/runners/{runner_id}").HandlerFunc(runners.UnregisterRunner).Methods("DELETE")
|
||||
|
||||
publicWebHookRouter := r.PathPrefix(webPath + "api").Subrouter()
|
||||
publicWebHookRouter.Use(StoreMiddleware, JSONMiddleware)
|
||||
|
@ -196,3 +196,19 @@ func RegisterRunner(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
helpers.WriteJSON(w, http.StatusOK, res)
|
||||
}
|
||||
|
||||
func UnregisterRunner(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
runner := context.Get(r, "runner").(db.Runner)
|
||||
|
||||
err := helpers.Store(r).DeleteGlobalRunner(runner.ID)
|
||||
|
||||
if err != nil {
|
||||
helpers.WriteJSON(w, http.StatusInternalServerError, map[string]string{
|
||||
"error": "Unknown error",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user