Skip to content

v1.0.0

Latest

Choose a tag to compare

@franklad franklad released this 25 Jul 01:04
9e3c062

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, and Name methods 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 Run method.
  • Graceful Shutdown: Implements Stop with context-aware shutdown, ensuring active connections are closed gracefully. Run handles http.ErrServerClosed to return nil for 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 NewHTTPResponse constructor with functional options (WithMessage, WithError, WithData, WithTimestamp) for building consistent JSON responses, and a WriteJSON method for easy encoding and writing to http.ResponseWriter.
  • Type-Safe Configuration: Uses a strongly-typed config struct 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, and time packages.
  • Performance: Minimal overhead by leveraging the standard library’s http.Server, suitable for performance-sensitive applications.