Documentation ¶
Index ¶
Constants ¶
const ( ProjectName = "APISERVER" DefaultConfigType = "yaml" DefaultEnvKeyReplace = "_" )
ProjectName defines the name of this API server project. Constants for default configurations.
Variables ¶
This section is empty.
Functions ¶
func LoadConfig ¶
LoadConfig loads the API server configuration from a given file or a default location.
Types ¶
type APIServer ¶
type APIServer struct { SecureServingInfo *SecureServingInfo InsecureServingInfo *InsecureServingInfo ShutdownTimeout time.Duration *gin.Engine RateLimit *RateLimitInfo // contains filtered or unexported fields }
APIServer wraps the gin.Engine with specific configurations and capabilities.
func (*APIServer) Close ¶
func (s *APIServer) Close()
Close gracefully shuts down both the insecure and secure servers.
func (*APIServer) InstallAPIs ¶
func (s *APIServer) InstallAPIs()
InstallAPIs installs specific endpoints to the server based on its configuration.
func (*APIServer) InstallMiddlewares ¶
func (s *APIServer) InstallMiddlewares()
InstallMiddlewares sets up any global middlewares for the server.
type CertKey ¶
type CertKey struct { CertFile string // Path to the PEM-encoded certificate. KeyFile string // Path to the PEM-encoded private key associated with the certificate. }
CertKey represents the certificate and key configuration for secure serving.
type CompletedConfig ¶
type CompletedConfig struct {
*Config
}
CompletedConfig represents a configuration that has been finalized and is ready for use.
func NewCompletedConfig ¶
func NewCompletedConfig(c *Config) CompletedConfig
func (CompletedConfig) New ¶
func (c CompletedConfig) New() (*APIServer, error)
New initializes and returns a new APIServer instance based on the completed configuration.
type Config ¶
type Config struct { SecureServing *SecureServingInfo InsecureServing *InsecureServingInfo Jwt *JwtInfo Mode string Middlewares []string Healthz bool EnableProfiling bool EnableMetrics bool RateLimit *RateLimitInfo }
Config represents the main configuration structure for the API server.
func NewConfig ¶
func NewConfig() *Config
NewConfig creates and returns a new Config instance with default settings.
func (*Config) Complete ¶
func (c *Config) Complete() CompletedConfig
Complete finalizes the Config by setting any missing values and returns a CompletedConfig.
type DefaultConfig ¶
DefaultConfig contains default values for server configurations.
type InsecureServingInfo ¶
type InsecureServingInfo struct {
Address string
}
InsecureServingInfo contains the configuration for serving the API over HTTP.
type RateLimitInfo ¶
type RateLimitInfo struct { RequsetPerSecond float64 // Number of tokens generated per second. Burst int // Maximum burst size. }
RateLimitConfig represents the configuration for rate limiting.
type SecureServingInfo ¶
SecureServingInfo encapsulates the configuration for serving the API over HTTPS.
func (*SecureServingInfo) Address ¶
func (s *SecureServingInfo) Address() string
Address constructs a complete address by combining BindAddress and BindPort.