gofr-dev / gofr

An opinionated GoLang framework for accelerated microservice development. Built in support for databases and observability.
https://gofr.dev
Apache License 2.0
3.6k stars 236 forks source link

Release v1.27.0 #1207

Closed aryanmehrotra closed 1 week ago

aryanmehrotra commented 1 week ago

Release v1.27.0

✨ Features

  1. UseMiddlewareWithContainer for Custom Middleware with Container Access
    Introduced the UseMiddlewareWithContainer method, which allows custom middleware to access the application's container. This provides access to essential services such as logging, configuration, and database instances, enabling middleware to modify request processing dynamically.

    Example Usage:

    
    import (
        "fmt"
        "net/http"
    
        "gofr.dev/pkg/gofr"
        "gofr.dev/pkg/gofr/container"
    )
    
    func main() {
        // Create a new GoFr application instance
        a := gofr.New()
    
        // Add custom middleware with container access
        a.UseMiddlewareWithContainer(customMiddleware)
    
       ....
    }
    
    // Define middleware with container access
    func customMiddleware(c *container.Container, handler http.Handler) http.Handler {
        return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
            c.Logger.Log("Hey! Welcome to GoFr")
            handler.ServeHTTP(w, r)
        })
    }
    ` 
    
    2.  **Migrations Support in MongoDB**  
    GoFr now introduces support for data migrations in MongoDB, enabling seamless modifications to your database schema and data. This includes adding new fields, modifying data types of existing fields, setting or removing indexes, and applying constraints to collections. All changes are meticulously tracked in the GoFr Migrations Table, ensuring a reliable and auditable history of database updates.
    ----------

🛠️ Fixes

  1. Remote Log URL Setup
    Resolved an issue where logs fetched from the remote log URL were missing correlation IDs. Logs now consistently include the correlation ID, ensuring better traceability.

  2. Entity DataType Documentation Update
    Enhanced the documentation for the Add-rest-handler feature by specifying supported data types in the entity structure, improving usability and reducing confusion.

  3. SQL Logs Level Adjustment
    Fixed the log level for successful SQL connections, which was mistakenly set to debug. It is now appropriately logged at the info level, aligning with logging best practices.