mirror of
https://github.com/lordmathis/llamactl.git
synced 2025-11-06 00:54:23 +00:00
Add DeleteInstance handler and route for instance management
This commit is contained in:
@@ -221,3 +221,21 @@ func (h *Handler) RestartInstance() http.HandlerFunc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h *Handler) DeleteInstance() http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
id := chi.URLParam(r, "id")
|
||||||
|
uuid, err := uuid.Parse(id)
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, "Invalid UUID format", http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := h.InstanceManager.DeleteInstance(uuid); err != nil {
|
||||||
|
http.Error(w, "Failed to delete instance: "+err.Error(), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
w.WriteHeader(http.StatusNoContent) // No content for successful deletion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ func SetupRouter(handler *Handler) *chi.Mux {
|
|||||||
// Instance management
|
// Instance management
|
||||||
r.Get("/", handler.GetInstance()) // Get instance details
|
r.Get("/", handler.GetInstance()) // Get instance details
|
||||||
r.Put("/", handler.UpdateInstance()) // Update instance configuration
|
r.Put("/", handler.UpdateInstance()) // Update instance configuration
|
||||||
// r.Delete("/", handler.DeleteInstance()) // Stop and remove instance
|
r.Delete("/", handler.DeleteInstance()) // Stop and remove instance
|
||||||
r.Post("/start", handler.StartInstance()) // Start stopped instance
|
r.Post("/start", handler.StartInstance()) // Start stopped instance
|
||||||
r.Post("/stop", handler.StopInstance()) // Stop running instance
|
r.Post("/stop", handler.StopInstance()) // Stop running instance
|
||||||
r.Post("/restart", handler.RestartInstance()) // Restart instance
|
r.Post("/restart", handler.RestartInstance()) // Restart instance
|
||||||
|
|||||||
Reference in New Issue
Block a user