2019-02-19 23:56:41 +00:00
|
|
|
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
|
|
|
// Use of this source code is governed by the Drone Non-Commercial License
|
|
|
|
// that can be found in the LICENSE file.
|
|
|
|
|
2019-03-13 21:47:47 +00:00
|
|
|
// +build !oss
|
|
|
|
|
2019-02-19 23:56:41 +00:00
|
|
|
package queue
|
|
|
|
|
2019-03-17 21:31:07 +00:00
|
|
|
import (
|
|
|
|
"net/http"
|
2019-02-19 23:56:41 +00:00
|
|
|
|
2019-03-17 21:31:07 +00:00
|
|
|
"github.com/drone/drone/core"
|
|
|
|
"github.com/drone/drone/handler/api/render"
|
|
|
|
"github.com/drone/drone/logger"
|
|
|
|
)
|
2019-02-19 23:56:41 +00:00
|
|
|
|
2019-03-17 21:31:07 +00:00
|
|
|
// HandleResume returns an http.HandlerFunc that processes
|
|
|
|
// an http.Request to pause the scheduler.
|
|
|
|
func HandleResume(scheduler core.Scheduler) http.HandlerFunc {
|
|
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
ctx := r.Context()
|
|
|
|
err := scheduler.Resume(ctx)
|
|
|
|
if err != nil {
|
|
|
|
render.InternalError(w, err)
|
|
|
|
logger.FromRequest(r).WithError(err).
|
|
|
|
Errorln("api: cannot resume scheduler")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
w.WriteHeader(http.StatusNoContent)
|
|
|
|
}
|
|
|
|
}
|