Release Notes for LessGo v1.0.4 🚀
Overview
Version v1.0.4 introduces enhanced HTTP server configuration capabilities to the LessGo framework. This release adds support for more granular HTTP server settings, allowing developers to tailor their server configurations according to development and production needs. 🔧✨
New Features
-
HTTP Server Configuration:
- ReadTimeout: Set the maximum duration for reading requests. Default is 5 seconds. ⏳
- WriteTimeout: Set the maximum duration for writing responses. Default is 5 seconds. ✍️
- IdleTimeout: Set the maximum duration to keep connections idle before closing. Default is 120 seconds. ⌛
- MaxHeaderSize: Configure the maximum size of request headers. Default is 1 MB. 📏
-
TLS Support:
- TLSCertFile: Path to the TLS certificate file. If provided, enables HTTPS. 🔒
- TLSKeyFile: Path to the TLS key file. If provided, enables HTTPS. 🔑
- MinVersion: Configured to TLS 1.2 for secure communication. 🔐
-
Security Configurations:
- EnableHSTS: Support for HTTP Strict Transport Security (HSTS). Enabled by default. 🛡️
- ContentSecurityPolicy: Default Content Security Policy (CSP) is set to
default-src 'self'
. 🛡️
-
Session Management:
- Session Store: Configurable session store type. Default is "memory". 🗄️
- Session Timeout: Configurable session timeout in seconds. Default is 3600 seconds (1 hour). ⏲️
Configuration Example
To leverage the new HTTP configuration features, you can initialize the HttpConfig
with custom settings like so:
httpCfg := LessGo.NewHttpConfig(
LessGo.WithReadTimeout(10),
LessGo.WithWriteTimeout(10),
LessGo.WithIdleTimeout(60),
LessGo.WithMaxHeaderSize(2<<20), // 2 MB
LessGo.WithTLSCertFile("path/to/server.cert"),
LessGo.WithTLSKeyFile("path/to/server.key"),
LessGo.WithHSTS(true),
LessGo.WithContentSecurityPolicy("default-src 'self'; script-src 'self'"),
LessGo.WithSessionStore("redis"),
LessGo.WithSessionTimeout(7200), // 2 hours
)
if err := App.Listen(addr, httpCfg); err != nil {
log.Fatalf("Server failed: %v", err)
}
In this release, the HTTP server configuration now provides greater flexibility and control over server behavior, making it easier to adapt to various environments and security requirements. 🌟
Happy coding! 🚀
Contributors:
- Hokam Singh (@hokamsingh) 🙌
- The LessGo Community 🌍
Release Date: August 2024 📅