h4 0.0.4 copy "h4: ^0.0.4" to clipboard
h4: ^0.0.4 copied to clipboard

A minimal HTTP framework for building elegant server applications.

0.0.1 #

  • Initial development release.

Retraction Notice #

Previous releases and versions 1.0.0, 1.0.1 and 1.1.0 were retracted due to immature development on the author's part.

Apologies for any distruptions, we are now prioritizing mature and stable development over speed.

0.0.2 #

  • New

    • requestBody utility: The first H4 utility function (readBody) is underway but not ready for production use.

      • Improved implementation of parseRequestBody correctly parses request body in non-binary, non-file formats as a string and returns the value.
    • Documentation for H4 router

    • Documentation and type definitions event handler

      • Renamed HandlerFunc type definition to EventHandler
      • Added documentation for Event Handler functions.
    • Made router[requestMethod] instances generic for increased type safety.

        // This gives an error.
        router.get<String>("/25/**", (event) => true);
      
        // This is valid
        router.get<bool>("/25/**", (event) => true);
      
    • Improved predictability of event handler responses: You can now return more types of values from event handlers.

    • Removed unecessary logs.

    • Used logger library when necessary to log.

  • Improved

    • CreateError Utility : It now uses named parameters for message and errorCode.
     router.get("/vamos", (event) {
     throw CreateError(message: 'Error occured', errorCode: 400);
    });
    

0.0.3 #

  • New

    • Breaking Changes to onError middleware.

      • The function passed to onError Middleware now has access to the error object (in string form), the stacktrace of the error (also in string form) and the event that triggered the error.

        h4.onError((String error, String stackTrace, H4Event event) {
          // Log the error to a service like sentry.
          logErrorToService(error, stackTrace, event.path);
        });
        
      • Documentation comments for public and internal API's including the H4 Class, defineEventHandler, H4Event and H4Router.

0.0.4 #

  • New

    • Improved error handling for asynchronous event handlers - Throwing an error in an async handler won't kill the process. It sends a JSON payload instead.

      {
      	"message": "Error message",
      	"statusMessage": "Internal server error",
      	"statusCode": 500
      }
      

      TODO - onError handler does not run when errors are thrown async event handlers. (Fix in next minor patc)

    • Support for extended server configuration : You can now specify if you want to start automatically or not. In the future you will be able to pass your own customer server and listen to requests with H4.

        void main() async {
          var app = createApp(port: 4000, autoStart: false);
          await app.start().then((h4) => print('App is running on ${h4?.port}'));
          var router = createRouter();
          app.use(router)
        };
      

      In the next patch release more server configuration objects will be added.

3
likes
0
points
64
downloads

Publisher

unverified uploader

Weekly Downloads

A minimal HTTP framework for building elegant server applications.

Repository (GitHub)
View/report issues

Topics

#http #server #api

License

unknown (license)

Dependencies

logger, meta

More

Packages that depend on h4