Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
func New ¶
func New( ctx context.Context, logger *logging.Logger, port string, staticDir string, shutdownTimeout time.Duration, ) *App
New creates and returns a new App instance with the provided dependencies. It initializes the HTTP server with default configuration and prepares it for handling requests.
Parameters:
- ctx: The context for the application lifecycle
- logger: A configured zap logger for application logging
- port: The port on which the server will listen for incoming requests
- staticDir: The directory containing static files to serve
- shutdownTimeout: The duration to wait during shutdown before forcefully terminating
func (*App) LaunchServer ¶
LaunchServer starts the HTTP server and manages its lifecycle. It will run until either a server error occurs or the application context is cancelled. When the context is cancelled, it triggers a graceful shutdown.
Returns an error if the server fails to start or encounters an error while running.
func (*App) SetServerShutdownTimeout ¶
SetServerShutdownTimeout configures the duration the server will wait during shutdown before forcefully terminating connections.
Parameters:
- t: The duration to wait during shutdown in nanoseconds
func (*App) ShutdownServer ¶
func (app *App) ShutdownServer()
ShutdownServer attempts to gracefully shut down the HTTP server within the configured shutdown timeout duration. If graceful shutdown fails, it forces the server to close. The shutdown status is logged through the application logger.