server

package
v0.0.0-...-ac5a270 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitDb

func InitDb(log utils.Logger, serviceName string, dbConfig DatabaseConfig) *gorm.DB

func InitializeServer

func InitializeServer(log utils.Logger, config ServerConfig) error

InitializeServer initializes a complete server with database, CORS, routes, and graceful shutdown

func ReadSecret

func ReadSecret(filePath string) (string, error)

ReadSecret reads a secret from a file path and returns it trimmed of whitespace

func SetupCORS

func SetupCORS(log utils.Logger, r *gin.Engine, config CORSConfig) http.Handler

func SetupCommonRoutes

func SetupCommonRoutes(log utils.Logger, r *gin.Engine, serviceName string)

func SetupHealthEndpoint

func SetupHealthEndpoint(log utils.Logger, r *gin.Engine, serviceName string)

func SetupJWTSecret

func SetupJWTSecret(log utils.Logger) string

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

type DatabaseConfig struct {
	Host   string
	Port   string
	Name   string
	Models []interface{}
}

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)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL