You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
portainer/api/http/server.go

54 lines
1.7 KiB

package http
import (
"github.com/portainer/portainer"
"net/http"
)
// Server implements the portainer.Server interface
type Server struct {
BindAddress string
AssetsPath string
UserService portainer.UserService
CryptoService portainer.CryptoService
JWTService portainer.JWTService
Settings *portainer.Settings
TemplatesURL string
EndpointConfig *portainer.EndpointConfiguration
}
// Start starts the HTTP server
func (server *Server) Start() error {
middleWareService := &middleWareService{
jwtService: server.JWTService,
}
var authHandler = NewAuthHandler()
authHandler.UserService = server.UserService
authHandler.CryptoService = server.CryptoService
authHandler.JWTService = server.JWTService
var userHandler = NewUserHandler(middleWareService)
userHandler.UserService = server.UserService
userHandler.CryptoService = server.CryptoService
var settingsHandler = NewSettingsHandler(middleWareService)
settingsHandler.settings = server.Settings
var templatesHandler = NewTemplatesHandler(middleWareService)
templatesHandler.templatesURL = server.TemplatesURL
var dockerHandler = NewDockerHandler(middleWareService)
dockerHandler.setupProxy(server.EndpointConfig)
var websocketHandler = NewWebSocketHandler()
websocketHandler.endpointConfiguration = server.EndpointConfig
var fileHandler = http.FileServer(http.Dir(server.AssetsPath))
handler := &Handler{
AuthHandler: authHandler,
UserHandler: userHandler,
SettingsHandler: settingsHandler,
TemplatesHandler: templatesHandler,
DockerHandler: dockerHandler,
WebSocketHandler: websocketHandler,
FileHandler: fileHandler,
}
return http.ListenAndServe(server.BindAddress, handler)
}