2018-06-11 13:13:19 +00:00
|
|
|
package status
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/gorilla/mux"
|
2018-09-10 10:01:38 +00:00
|
|
|
httperror "github.com/portainer/libhttp/error"
|
2022-05-22 05:34:09 +00:00
|
|
|
portainer "github.com/portainer/portainer/api"
|
|
|
|
"github.com/portainer/portainer/api/demo"
|
2019-03-21 01:20:14 +00:00
|
|
|
"github.com/portainer/portainer/api/http/security"
|
2018-06-11 13:13:19 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Handler is the HTTP handler used to handle status operations.
|
|
|
|
type Handler struct {
|
|
|
|
*mux.Router
|
2022-05-22 05:34:09 +00:00
|
|
|
Status *portainer.Status
|
|
|
|
demoService *demo.Service
|
2018-06-11 13:13:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewHandler creates a handler to manage status operations.
|
2022-05-22 05:34:09 +00:00
|
|
|
func NewHandler(bouncer *security.RequestBouncer, status *portainer.Status, demoService *demo.Service) *Handler {
|
2018-06-11 13:13:19 +00:00
|
|
|
h := &Handler{
|
2022-05-22 05:34:09 +00:00
|
|
|
Router: mux.NewRouter(),
|
|
|
|
Status: status,
|
|
|
|
demoService: demoService,
|
2018-06-11 13:13:19 +00:00
|
|
|
}
|
|
|
|
h.Handle("/status",
|
|
|
|
bouncer.PublicAccess(httperror.LoggerHandler(h.statusInspect))).Methods(http.MethodGet)
|
2019-09-25 20:38:11 +00:00
|
|
|
h.Handle("/status/version",
|
2022-07-14 23:09:38 +00:00
|
|
|
bouncer.AuthenticatedAccess(http.HandlerFunc(h.version))).Methods(http.MethodGet)
|
2018-06-11 13:13:19 +00:00
|
|
|
|
|
|
|
return h
|
|
|
|
}
|