mirror of
https://github.com/m1k1o/neko-rooms.git
synced 2026-11-03 07:01:35 -06:00
pull images.
This commit is contained in:
@@ -41,4 +41,10 @@ func (manager *ApiManagerCtx) Mount(r chi.Router) {
|
||||
r.Post("/restart", manager.roomGenericAction(manager.rooms.Restart))
|
||||
r.Post("/recreate", manager.roomRecreate)
|
||||
})
|
||||
|
||||
r.Route("/pull", func(r chi.Router) {
|
||||
r.Get("/", manager.roomPullStatus)
|
||||
r.Post("/", manager.roomPullStart)
|
||||
r.Delete("/", manager.roomPullStop)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -169,3 +169,38 @@ func (manager *ApiManagerCtx) roomGenericAction(action func(id string) error) fu
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
}
|
||||
}
|
||||
|
||||
func (manager *ApiManagerCtx) roomPullStart(w http.ResponseWriter, r *http.Request) {
|
||||
request := types.PullStart{}
|
||||
|
||||
if err := json.NewDecoder(r.Body).Decode(&request); err != nil {
|
||||
http.Error(w, err.Error(), 400)
|
||||
return
|
||||
}
|
||||
|
||||
err := manager.rooms.PullStart(request)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), 500)
|
||||
return
|
||||
}
|
||||
|
||||
response := manager.rooms.PullStatus()
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(response)
|
||||
}
|
||||
|
||||
func (manager *ApiManagerCtx) roomPullStatus(w http.ResponseWriter, r *http.Request) {
|
||||
response := manager.rooms.PullStatus()
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(response)
|
||||
}
|
||||
|
||||
func (manager *ApiManagerCtx) roomPullStop(w http.ResponseWriter, r *http.Request) {
|
||||
err := manager.rooms.PullStop()
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), 500)
|
||||
return
|
||||
}
|
||||
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user