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"
|
2019-03-21 01:20:14 +00:00
|
|
|
"github.com/portainer/portainer/api"
|
|
|
|
"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
|
|
|
|
Status *portainer.Status
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewHandler creates a handler to manage status operations.
|
|
|
|
func NewHandler(bouncer *security.RequestBouncer, status *portainer.Status) *Handler {
|
|
|
|
h := &Handler{
|
|
|
|
Router: mux.NewRouter(),
|
|
|
|
Status: status,
|
|
|
|
}
|
|
|
|
h.Handle("/status",
|
|
|
|
bouncer.PublicAccess(httperror.LoggerHandler(h.statusInspect))).Methods(http.MethodGet)
|
2019-09-25 20:38:11 +00:00
|
|
|
h.Handle("/status/version",
|
|
|
|
bouncer.RestrictedAccess(http.HandlerFunc(h.statusInspectVersion))).Methods(http.MethodGet)
|
2018-06-11 13:13:19 +00:00
|
|
|
|
|
|
|
return h
|
|
|
|
}
|