Repository navigation
Release Notes - v1.0.0
Overview
This is the initial major release of the server package, a lightweight and configurable HTTP server library for Go applications. It provides a simple, type-safe, and extensible interface for creating and managing HTTP servers with support for TLS, customizable timeouts, and graceful shutdown. Additionally, it includes a standardized JSON response helper for consistent API responses, featuring options for status, message, error, data, and timestamp. Designed with emphasis on simplicity, reliability, and adherence to Go best practices for building robust server applications.
Date: July 24, 2025
Version: v1.0.0
Module: github.com/franklad/server
Key Features
- Simple Interface: Provides a clean API with
NewHTTPServer,Run,Stop, andNamemethods for creating, starting, stopping, and identifying an HTTP server. - Configurable Options: Supports functional options (
WithHost,WithPort,WithReadTimeout,WithWriteTimeout,WithIdleTimeout,WithTLS) for flexible server configuration. - TLS Support: Enables HTTPS with optional TLS certificate and key configuration, seamlessly integrated into the
Runmethod. - Graceful Shutdown: Implements
Stopwith context-aware shutdown, ensuring active connections are closed gracefully.Runhandleshttp.ErrServerClosedto returnnilfor clean shutdowns. - Customizable Timeouts: Allows configuration of read, write, and idle timeouts with sensible defaults (5s, 10s, 120s respectively) to optimize server performance and reliability.
- Standardized JSON Responses: Includes a
NewHTTPResponseconstructor with functional options (WithMessage,WithError,WithData,WithTimestamp) for building consistent JSON responses, and aWriteJSONmethod for easy encoding and writing tohttp.ResponseWriter. - Type-Safe Configuration: Uses a strongly-typed
configstruct and functional options pattern to prevent misconfiguration and improve code safety. - Error Handling: Returns errors for all failure cases (e.g., server startup, shutdown, JSON encoding) instead of panicking, promoting robust application behavior.
- Best Practices:
- Adheres to Go conventions with clear, idiomatic code.
- Comprehensive godoc-friendly comments for easy understanding and usage.
- Minimal dependencies, relying only on the standard library's
net/http,encoding/json, andtimepackages.
- Performance: Minimal overhead by leveraging the standard library’s
http.Server, suitable for performance-sensitive applications.