Skip to content

Commit

Permalink
feat(runners): unregister endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
fiftin committed Mar 27, 2024
1 parent 7a1e080 commit 60d7598
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions api/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 16 additions & 0 deletions api/runners/runners.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 60d7598

Please sign in to comment.