Documentation
¶
Overview ¶
Package server provides configuration management for the dehydrated-api-go server. It handles loading and validating server configuration from YAML files, including server settings, plugin configurations, and logging options.
Package server provides the HTTP server implementation for the dehydrated-api-go application. It handles server lifecycle management, configuration loading, and graceful shutdown.
Index ¶
- type Config
- type Server
- func (s *Server) GetPort() int
- func (s *Server) PrintDehydratedConfig()
- func (s *Server) PrintInfo(v, i bool)
- func (s *Server) PrintServerConfig()
- func (s *Server) PrintVersion()
- func (s *Server) Shutdown()
- func (s *Server) Start()
- func (s *Server) WithConfig(path string) *Server
- func (s *Server) WithDomainService() *Server
- func (s *Server) WithLogger() *Server
- func (s *Server) WithVersionInfo(v, c, b string) *Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Server configuration
Port int `yaml:"port"` // Port number for the HTTP server (1-65535)
// Dehydrated configuration
DehydratedBaseDir string `yaml:"dehydratedBaseDir"` // Base directory for dehydrated client files
// DehydratedConfigFile specifies the path to the dehydrated configuration file.
// This file is typically located under the base directory and contains
// dehydrated client-specific settings.
DehydratedConfigFile string `yaml:"dehydratedConfigFile"`
// EnableWatcher determines whether the file watcher is active.
// When enabled, the server monitors for changes in the dehydrated configuration.
EnableWatcher bool `yaml:"enableWatcher"`
// Logging configuration
Logging *logger.Config `yaml:"logging"` // Configuration for the application logger
// Authentication configuration
Auth *auth.Config `yaml:"auth"` // Azure AD authentication configuration
Plugins map[string]config.PluginConfig `yaml:"plugins"`
// contains filtered or unexported fields
}
Config holds the application configuration for the dehydrated-api-go server. It includes settings for the HTTP server, plugin management, dehydrated client, and logging configuration.
func NewConfig ¶
func NewConfig() *Config
NewConfig creates a new Config instance with default values. The default configuration includes: - Port: 3000 - DehydratedBaseDir: "." - DehydratedConfigFile: "config" - EnableWatcher: false - Logging: default logger configuration
func (*Config) DomainsFile ¶
DomainsFile returns the absolute path to the domains.txt file. This file contains the list of domains managed by the dehydrated client.
func (*Config) Load ¶
Load loads configuration from a YAML file and merges it with defaults. If the file doesn't exist or has invalid content, the default configuration is returned. The method merges non-zero values from the file with the existing configuration.
func (*Config) Validate ¶
Validate checks if the configuration is valid and returns an error if any issues are found. It validates: - Port number (must be between 1 and 65535) - Dehydrated base directory (must exist) - Plugin configurations (paths must exist and be absolute)
func (*Config) WithBaseDir ¶
WithBaseDir sets the dehydrated base directory in the configuration. This method returns the config instance for method chaining.
type Server ¶
type Server struct {
Version string
Commit string
BuildTime string
Config *Config
Logger *zap.Logger
// contains filtered or unexported fields
}
Server represents a running server instance that manages the HTTP server lifecycle. It handles server startup, shutdown, and maintains the application state.
func (*Server) PrintDehydratedConfig ¶
func (s *Server) PrintDehydratedConfig()
func (*Server) PrintServerConfig ¶
func (s *Server) PrintServerConfig()
func (*Server) PrintVersion ¶
func (s *Server) PrintVersion()
func (*Server) Shutdown ¶
func (s *Server) Shutdown()
Shutdown gracefully shuts down the server and its associated resources.
func (*Server) Start ¶
func (s *Server) Start()
Start starts the server and begins listening for requests.