Skip to content

Releases: gofr-dev/gofr

v1.31.0

20 Jan 11:18
fc8616b
Compare
Choose a tag to compare

Release v1.31.0

🚀 Features :

  1. Support for ScyllaDB as a Data Source
    ScyllaDB is now supported as a data source in GoFr. The following methods are supported:

    Query(dest any, stmt string, values ...any) error  
    QueryWithCtx(ctx context.Context, dest any, stmt string, values ...any) error  
    Exec(stmt string, values ...any) error  
    ExecWithCtx(ctx context.Context, stmt string, values ...any) error  
    ExecCAS(dest any, stmt string, values ...any) (bool, error)  
    NewBatch(name string, batchType int) error  
    NewBatchWithCtx(ctx context.Context, name string, batchType int) error  
    BatchQuery(name, stmt string, values ...any) error  
    BatchQueryWithCtx(ctx context.Context, name, stmt string, values ...any) error  
    ExecuteBatchWithCtx(ctx context.Context, name string) error  

    To integrate ScyllaDB into your application, use the AddScyllaDB method:

    client := scylladb.New(scylladb.Config{
        Host:     app.Config.Get("SCYLLADB_HOST"),
        Keyspace: app.Config.Get("SCYLLADB_KEYSPACE"),
        Port:     app.Config.GetInt("SCYLLADB_PORT"),
        Username: app.Config.Get("SCYLLADB_USERNAME"),
        Password: app.Config.Get("SCYLLADB_PASSWORD"),
    })
    app.AddScyllaDB(client)

    For detailed instructions, refer to the ScyllaDB documentation.

  2. Built-in Tracing for Interservice gRPC Calls
    All interservice gRPC calls in GoFr now include in-built tracing support.

    • Prerequisite: Ensure gofr-cli v0.3.0 is installed. To install gofr-cli, run:

      go install gofr.dev/cli/gofr@latest
    • To generate the gRPC client, run:

      gofr wrap grpc client -proto=path/to/your/proto/file

    For detailed instructions on setting up the gRPC Client in GoFr, refer to the documentation. You can also explore an example gRPC client implementation in the examples folder.

Full Changelog: v1.30.0...v1.31.0

v1.30.0

10 Jan 06:24
9e01054
Compare
Choose a tag to compare

Release v1.30.0

🚀 Features

1. GoFr's Context Support in gRPC Handlers

Introduced context integration for gRPC handlers, enabling efficient dependency and tracing management.
Automatically generates gRPC handler templates with built-in support for gofr's context using the gofr wrap grpc command of gofr cli.

Note: For details on setting up Protocol Buffers and gRPC in GoFr, visit the official Documentation and Example

🔧 Fixes

1. ExpectSelect Update in SQL Mocks

Refactored the ExpectSelect function in SQL mocks. Users can now set expected responses using the ReturnsResponse method, ensuring accurate mock behavior during tests.

  • Example Usage:

    var result, actualResult Response
    
    mockContainer, sqlMock := NewMockContainer(t)
    ctx := &gofr.Context{
      Container: mockContainer,
    }
    
    expectedResult := Response{
      // ... fill with expected values
    }
    
    sqlMock.ExpectSelect(ctx, &result, query).ReturnsResponse(expectedResult)
    
    ctx.SQL.Select(ctx, &actualResult, query)
    
    assert.Equal(t, actualResult, expectedResult)

2. Environment Variable Handling

  • OS-level environment variables now override values from .env, .<APP_ENV>.env configurations, ensuring consistent behaviour across environments.

3. Improved Logging

  • Removed sensitive information (e.g., usernames and passwords) from MongoDB connection logs by replacing uri with host.
  • Fixed inaccurate Redis connection logs and removed unnecessary SQL connection logs when no SQL connection is established.
  • Added error logs for database migration failures, improving visibility during debugging.

4. Security Fixes

  • Updated golang.org/x/crypto to v0.31.0 to resolve potential authorization bypass issues.
  • Updated go.mod in pkg/gofr/datasource/mongo for compatibility with Go commands.

v1.29.0

24 Dec 13:12
5bc6ec2
Compare
Choose a tag to compare

Release v1.29.0


✨ Features:

  1. Custom Metadata in Responses
    Users can now include metadata in API responses using the response.Response struct. This allows for clean, structured responses while providing additional contextual information.
    • Response Structure:
      • With Metadata:
        {
            "data": {},
            "metadata": {}
        }
      • Without Metadata:
        {
            "data": {}
        }
    • Example Usage:
      func HelloHandler(c *gofr.Context) (interface{}, error) {
          headers := map[string]string{
              "X-Custom-Header": "CustomValue",
          }
      
          metaData := map[string]any{
              "environment": "staging",
              "timestamp":   time.Now(),
          }
      
          return response.Response{
              Data:     map[string]string{"message": "Hello, World!"},
              Metadata: metaData,
              Headers:  headers,
          }, nil
      }

  1. Support for Redis Database Selection:
  • Introduces a new config REDIS_DB to specify the Redis database index to be used.
  • Example usage:
    os.Setenv("REDIS_DB", "1")

🛠️ Fixes:

  1. Disconnected Spans Exported for Remote-log-url:
  • Resolves an issue where disconnected spans were created for each fetch request of the remote log.
  • Ensures that all traces exported for a single HTTP request have spans in hierarchy.
  1. Hardcoded Ports Fix:
  • Addresses the issue of hardcoded ports within the codebase.
  • Now allows for dynamic port configuration, improving flexibility and deployment scenarios.
  1. Lowercase Default Paths for CRUD Helpers:
  • Changes the default paths for CRUD helpers to be in lowercase.
  • Helps avoid confusion caused by case sensitivity on certain servers.

v1.28.2

11 Dec 07:29
16de8ae
Compare
Choose a tag to compare

Release v1.28.2

Fixes 🛠️️ :

  • Set Content-Type: application/json for HTTP service that doesn't explicitly provide a content type, when calling GET, POST, or similar methods during interservice communication.

v1.28.1

09 Dec 08:44
f8639d4
Compare
Choose a tag to compare

Release v1.28.1

🛠️ Fixes:

  1. Improved Static File Metrics

    • Metrics middleware now accurately identifies and tracks static file requests, including handling file paths with query parameters.

    Example:
    Metrics will now correctly log /static/example.js or /static/example.js?v=42.

  2. Subscription Handler Validation

    • Improved error handling in App.Subscribe().
    • Ensures that topic and handler parameters are validated to prevent runtime errors.
    • Logs detailed error messages for invalid subscriptions.

v1.28.0

27 Nov 12:51
4df66c5
Compare
Choose a tag to compare

✨ Features:

Custom Response Headers Support:
Users can add custom HTTP response headers using the Response struct. This feature helps add extra information, such as security policies or other metadata, to improve communication between clients and servers.

  • Example usage:
        return response.Response{
            Data:    "Hello World from new Server",
            Headers: map[string]string{"X-Custom-Header": "CustomValue", "X-Another-Header": "AnotherValue"},
        }` 

OpenTSDB Support:
Users can integrate OpenTSDB to store and retrieve time-series data.

  • Methods include:

    • PutDataPoints: Send data to OpenTSDB.
    • QueryDataPoints: Retrieve data based on specified parameters.
    • GetAggregators: Get available aggregation functions.
    • QueryAnnotation, PostAnnotation, PutAnnotation, DeleteAnnotation: Manage annotations in OpenTSDB.
  • To import GoFr's external OpenTSDB driver:
    go get gofr.dev/pkg/gofr/datasource/opentsdb@latest

type OpenTSDB interface { 
    HealthChecker 
    PutDataPoints(ctx context.Context, data any, queryParam string, res any) error
    QueryDataPoints(ctx context.Context, param any, res any) error 
    QueryLatestDataPoints(ctx context.Context, param any, res any) error 
    GetAggregators(ctx context.Context, res any) error QueryAnnotation(ctx context.Context, queryAnnoParam map[string]any, res any) error 
    PostAnnotation(ctx context.Context, annotation any, res any) error
    PutAnnotation(ctx context.Context, annotation any, res any) error 
    DeleteAnnotation(ctx context.Context, annotation any, res any) error 
}

Support for Binding Binary/Octet Stream:
Users can bind binary/octet-stream content directly to []byte slices using GoFr context.

  • Example usage:

        var result []byte
        err := req.Bind(&result)
        if err != nil {
          log.Fatalf("Bind error: %v", err)
        } 

🛠️ Fixes:

Milliseconds Logged as Microseconds:

  • Previously, operation duration was calculated in milliseconds but was incorrectly logged as microseconds, which led to confusion. This has been fixed to ensure that logs display the accurate duration in microseconds.

Dgraph Datasource Panic Fix

  • Fixed an issue where the Dgraph datasource would panic due to an uninitialized tracer when added as an external datasource. This bug has been addressed.

Solr Methods Fixes:

  • Fixed errors occurring in the following Solr datasource methods: Update, Delete, ListFields, Retrieve, AddField, UpdateField, DeleteField.
  • Updated documentation and provided a working example, accordingly.

Deprecated UseMiddlewareWithContainer Method:

  • The method UseMiddlewareWithContainer has been deprecated and will be removed in future releases. Developers should use the *App.UseMiddleware method instead, which does not depend on the container.

Static File Path Handling Fix:

  • Fixed an issue in the AddStaticFiles method where file paths were not correctly resolved when they didn't start with ./ or were not absolute paths. The fix ensures that the correct file path is registered for static file serving.

v1.27.1

17 Nov 04:50
9a97ec5
Compare
Choose a tag to compare

Release v1.27.1

🛠️ Fixes

Fix Google Pubsub Panic

The callback function for the Google client Subscribe function was configured to fetch one message per Subscribe call. Still, at times the message was being sent to a closed channel causing unexpected behaviour. Fixed the issue of receiving messages on a channel that closes only on application shutdown.

v1.27.0

15 Nov 11:33
9990977
Compare
Choose a tag to compare

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.

v1.26.0

07 Nov 09:14
f87b8c1
Compare
Choose a tag to compare

Release v1.26.0

✨ Features

1. Support for NATS as External Pub-Sub

We have added support for NATS as an external pub/sub service in GoFr. Users can now easily set up NATS for message publishing and subscribing by configuring it via app.AddPubSub. Here’s a quick example:

app.AddPubSub(nats.New(&nats.Config{
    Server:    "nats://localhost:4222",
    CredsFile: "",
    Stream: nats.StreamConfig{
        Stream:   "my-stream",
        Subjects: []string{"order-logs", "products"},
    },
    MaxWait:     5 * time.Second,
    MaxPullWait: 500,
    Consumer:    "my-consumer",
}, app.Logger()))

To inject NATS, import it using the following command:

go get gofr.dev/pkg/gofr/datasources/pubsub/nats

Refer to our documentation for detailed setup instructions.

2. New Environment Variable DB_CHARSET

Introduced a new environment variable DB_CHARSET to make the MySQL character set configurable. By default, DB_CHARSET is set to utf8. However, setting it to utf8mb4 is recommended for full Unicode support, including emojis and special characters.

3. Enhanced CLI with TUI Elements (Spinners and Progress Bar)

This release enhances the GoFr command-line experience by introducing Text User Interface (TUI) elements, including spinners and a progress bar for visual feedback during command execution.

Check out an example in examples/sample-cmd to see this in action.

4. New Examples for Remote File Server Interaction

We’ve added new examples in the examples/using-add-filestore directory, demonstrating how to interact with remote file servers using GoFr. This addition provides a convenient reference for developers working with remote file management.


🛠️ Fixes

1. Fix: Invalid ClickHouse Documentation

Updated the ClickHouse package documentation to highlight only the relevant parts, improving readability and maintainability.

Release v1.25.0

04 Nov 11:01
ca59aa0
Compare
Choose a tag to compare

Release v1.25.0

✨ Features

BadgerDB Tracing

  • Added context support and tracing for BadgerDB datasource operations, enhancing observability and tracking within the BadgerDB storage layer.(Released pkg/gofr/datasource/kv-store/badger - v0.2.0)

Redis Authentication Support

  • Users can now connect to Redis instances requiring a username, password, or both. Configure these credentials in the .env file located in the configs folder:

    • REDIS_USER: User credential for connecting to the Redis server. Multiple users with different permissions can be configured within a single Redis instance. For more details, refer to the official Redis documentation.

    • REDIS_PASSWORD: Password credential required only if authentication is enabled on the Redis instance.

Enhanced Authentication Retrieval in Context

  • The GetAuthInfo method on the context provides easy access to various authentication methods, allowing developers to retrieve:

    • JWT Claims: Use GetAuthInfo().GetClaims() when OAuth is enabled, returning a jwt.MapClaims response.

    • Username: Use GetAuthInfo().GetUsername() for basic authentication, returning the username or an empty string if basic auth is not enabled.

    • API Key: Use GetAuthInfo().GetAPIKey() for API key-based authentication, returning the API key or an empty string if API key auth is not enabled.


🛠️ Fixes

Static File Route Issue

  • Resolved a bug in the AddStaticFiles method where static files could not be accessed via specified routes. Now, running the following code:

    func main() {
        app := gofr.New()
        app.AddStaticFiles("/", "./static")
        app.Run()
    }

    Files within the ./static directory can be accessed properly, e.g., http://localhost:9000/abc.jpeg, without encountering a "route not registered" error.

Controlled Access to OpenAPI Files

  • Prevented direct access to the openapi.json file via static routes. The file is now restricted to access through explicitly defined routes such as /.well-known/swagger or /.well-known/openapi.json for secure and controlled API documentation access.