2018-06-11 13:13:19 +00:00
|
|
|
package upload
|
|
|
|
|
|
|
|
import (
|
2023-09-01 22:27:02 +00:00
|
|
|
"net/http"
|
|
|
|
|
2022-10-17 18:29:12 +00:00
|
|
|
portainer "github.com/portainer/portainer/api"
|
2019-03-21 01:20:14 +00:00
|
|
|
"github.com/portainer/portainer/api/http/security"
|
2023-09-01 22:27:02 +00:00
|
|
|
httperror "github.com/portainer/portainer/pkg/libhttp/error"
|
2018-06-11 13:13:19 +00:00
|
|
|
|
|
|
|
"github.com/gorilla/mux"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Handler is the HTTP handler used to handle upload operations.
|
|
|
|
type Handler struct {
|
|
|
|
*mux.Router
|
|
|
|
FileService portainer.FileService
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewHandler creates a handler to manage upload operations.
|
2023-06-16 13:44:22 +00:00
|
|
|
func NewHandler(bouncer security.BouncerService) *Handler {
|
2018-06-11 13:13:19 +00:00
|
|
|
h := &Handler{
|
|
|
|
Router: mux.NewRouter(),
|
|
|
|
}
|
|
|
|
h.Handle("/upload/tls/{certificate:(?:ca|cert|key)}",
|
2019-10-07 03:10:51 +00:00
|
|
|
bouncer.AdminAccess(httperror.LoggerHandler(h.uploadTLS))).Methods(http.MethodPost)
|
2018-06-11 13:13:19 +00:00
|
|
|
return h
|
|
|
|
}
|