Documentation
¶
Index ¶
- func InitDb(log utils.Logger, serviceName string, dbConfig DatabaseConfig) *gorm.DB
- func InitializeServer(log utils.Logger, config ServerConfig) error
- func ReadSecret(filePath string) (string, error)
- func SetupCORS(log utils.Logger, r *gin.Engine, config CORSConfig) http.Handler
- func SetupCommonRoutes(log utils.Logger, r *gin.Engine, serviceName string)
- func SetupHealthEndpoint(log utils.Logger, r *gin.Engine, serviceName string)
- func SetupJWTSecret(log utils.Logger) string
- func SetupSwaggerEndpoints(log utils.Logger, r *gin.Engine, config RouteConfig)
- type CORSConfig
- type DatabaseConfig
- type RouteConfig
- type ServerConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitializeServer ¶
func InitializeServer(log utils.Logger, config ServerConfig) error
InitializeServer initializes a complete server with database, CORS, routes, and graceful shutdown
func ReadSecret ¶
ReadSecret reads a secret from a file path and returns it trimmed of whitespace
func SetupCommonRoutes ¶
func SetupHealthEndpoint ¶
func SetupJWTSecret ¶
SetupJWTSecret reads JWT secret from file or environment variable
func SetupSwaggerEndpoints ¶
func SetupSwaggerEndpoints(log utils.Logger, r *gin.Engine, config RouteConfig)
Types ¶
type CORSConfig ¶
type CORSConfig struct {
AllowedOrigins []string
AllowedMethods []string
AllowedHeaders []string
ExposeHeaders []string
AllowCredentials bool
UseGorillaHandlers bool
}
func DefaultCORSConfig ¶
func DefaultCORSConfig() CORSConfig
type DatabaseConfig ¶
func GetDatabaseConfig ¶
func GetDatabaseConfig(models []interface{}) DatabaseConfig
func GetDatabaseConfigWithDefaults ¶
func GetDatabaseConfigWithDefaults(models []interface{}, defaultDBName string) DatabaseConfig
type RouteConfig ¶
type RouteConfig struct {
ServiceName string
}
type ServerConfig ¶
type ServerConfig struct {
ServiceName string
Port string
DatabaseConfig DatabaseConfig
CORSConfig CORSConfig
RouteConfig RouteConfig
SetupCustomRoutes func(log utils.Logger, r *gin.Engine, db *gorm.DB)
}
Click to show internal directories.
Click to hide internal directories.