Release v1.56.0
🚀 Features
🔹 CORS Multiple Origins Support
GoFr's CORS middleware now supports multiple allowed origins, enabling fine-grained access control for applications serving multiple frontends or admin panels.
- Comma-Separated Origins: Configure multiple origins via the
ACCESS_CONTROL_ALLOW_ORIGINenvironment variable - Dynamic Origin Matching: On each request, the
Originheader is matched against the allowed set and only the matched origin is returned in the response (per HTTP spec) - Correct Caching: Adds
Vary: Originheader when a specific origin is matched, ensuring proxies and CDNs cache responses correctly - Fully Backward-Compatible: Single origin and wildcard (
*) work exactly as before
Configuration Example
# Single origin (existing behavior)
ACCESS_CONTROL_ALLOW_ORIGIN=https://app.example.com
# Multiple origins (new)
ACCESS_CONTROL_ALLOW_ORIGIN=https://app.example.com,https://admin.example.com🔧 Enhancements
🔹 Selective Migration Record Tracking
Migrations now only insert gofr_migrations records into databases that were actually used by the UP function, instead of all connected databases. Previously, running a migration that only touched MySQL would still insert migration records into Redis, MongoDB, Cassandra, and every other connected database — leading to phantom records, wasted I/O, and a misleading audit trail. Each datasource is now wrapped with lightweight usage-tracking before UP() executes, and only touched databases receive the migration record.
🛠️ Fixes
-
WebSocket Nil Pointer Panic — Fixed a nil pointer dereference in
WriteMessageToSocketwhen no WebSocket connection exists in the context. It now returnsErrConnectionNotFoundinstead of panicking. -
File Logger Descriptor Leak —
NewFileLogger()opens a file viaos.OpenFilebut previously had no way to close it, causing file descriptor leaks. Added aClose()method to the logger, which is now called duringApp.Shutdown()(HTTP/gRPC) and aftercmd.Run()(CLI apps).Fatal/Fatalfalso now callfile.Sync()before exiting to flush buffered log data. -
Cron Job Duration Log Format — Fixed
%!s(float64=...)in cron job completion logs by keepingdurationastime.Durationinstead of converting tofloat64. Logs now show human-readable durations (e.g.,25.071286msinstead of%!s(float64=0.025071286)). -
UpdateOne Breaking Change Reverted — Reverted the
Mongointerface'sUpdateOnereturn type from(int64, error)back toerror, fixing a breaking change introduced in v1.55.0. The migration lock refresh now usesUpdateMany(which already returns the neededModifiedCount) with a filter that guarantees at most one document matches. -
Dependency Updates — Consolidated minor dependency updates and bumped
github.com/go-jose/go-jose/v4for security improvements.