Skip to content

LessGo v0.2.8

Compare
Choose a tag to compare
@hokamsingh hokamsingh released this 21 Aug 05:59
· 96 commits to main since this release

Go-Logo_Aqua

Release Notes

We are excited to announce the release of LessGo v0.2.8, which brings several powerful new features and improvements to our lightweight, Go-based web framework. This version introduces enhanced request and response handling, streamlined routing capabilities, and more robust context management. Here's what's new:

New Features

  1. Custom Context (Context) Integration

    • Enhanced Request and Response Handling: Introducing a custom Context structure (Context) that provides utility methods for accessing request parameters, handling request bodies, and sending JSON responses. This makes it easier to work with HTTP requests and responses in a more expressive and convenient way.
    • Request Body Parsing: The Context now includes a Body method to parse JSON request bodies into Go structs. This simplifies the handling of incoming data while ensuring type safety and ease of use.
    • JSON Response Handling: The Context provides a JSON method that streamlines the process of sending JSON responses to the client. It automatically sets the Content-Type header and encodes the response data into JSON format.
  2. Routing Enhancements

    • Express-style HTTP Methods: LessGo now supports all standard HTTP methods (GET, POST, PUT, DELETE, etc.) directly within the router. You can now define routes using expressive methods like r.Get, r.Post, r.Put, and r.Delete, making route definitions cleaner and more intuitive.
    • Route Middleware Support: The framework now supports middleware chaining for routes. Middleware functions can be applied to routes to handle tasks such as request logging, error handling, and CORS management.
  3. Request Body Persistence

    • Non-destructive JSON Parsing: The framework's JSON parser middleware now reads and stores the request body without consuming it. This allows the body to be accessed multiple times, ensuring that your handlers can always access the original request data.
    • Accessor for Parsed JSON Body: A new GetJSONBody method has been added to the Context, allowing easy retrieval of the parsed JSON body from the request context. This provides a seamless way to work with request data across different parts of your application.
  4. Utilities and Middleware

    • Serve Static Files: The framework now includes improved support for serving static files, with easy-to-use methods for defining static file directories.
    • Middleware Enhancements: Middleware functions for CORS, rate limiting, and JSON parsing have been refined to work seamlessly with the new context and routing features.

Bug Fixes and Improvements

  • Improved Error Handling: Enhanced error handling within the context and middleware, ensuring more informative error messages and smoother request processing.
  • Optimized Performance: Various optimizations to the request handling pipeline to reduce overhead and improve response times.
  • Refactoring and Code Cleanup: Significant refactoring of the internal codebase for better maintainability and extensibility.

Breaking Changes

  • CustomHandler to http.HandlerFunc Conversion: The introduction of custom context handling may require updates to existing handlers. Make sure to wrap existing http.HandlerFunc handlers using the new context-aware methods to maintain compatibility.

We hope you find these new features and improvements valuable as you continue to build with LessGo. As always, we welcome your feedback and contributions. Happy coding!

Contributors:

Release Date: August 2024