go-json-rest v2.1.0 Release Notes

Release Date: 2014-11-30 // over 9 years ago
  • Main changes

    • ๐Ÿ’… Apache-style access log
    • ๐Ÿ‘Œ Improved timer and recorder middlewares
    • ๐Ÿ†• new JSONP middleware
    • ๐Ÿ‘‰ Make the gzip middleware support streaming responses

    ๐Ÿ’… Apache-style access log

    ๐ŸŒฒ Go-Json-Rest now reuses the well known Apache log formatting syntax to define the access log.

    With this new feature, the user can define his own record format:

    rest.ResourceHandler{ LoggerFormat: "%t %r %s %b", }
    

    or pick a predefined one:

    rest.ResourceHandler{ LoggerFormat: rest.CommonLogFormat, }
    

    0๏ธโƒฃ or just just ignore this field and get a default, development friendly access log.

    ๐ŸŒฒ This is an implementation of a subset of the Apache mod_log_config syntax. Some options are not implemented yet, I expect the support can grow over time.
    ๐ŸŒฒ See http://httpd.apache.org/docs/2.0/mod/mod_log_config.html for reference.
    ๐Ÿ‘€ And See Godoc for the list of supported options and predefined formats: https://godoc.org/github.com/ant0ine/go-json-rest/rest#AccessLogFormat

    ๐Ÿ—„ Note: Compatibility with the existing JSON logging is maintained. This JSON logging feature may be deprecated in the future is favor of a more powerful one. Internally, logMiddleware is replaced by accessLogApacheMiddleware and accessLogJsonMiddleware.

    ๐Ÿ‘Œ Improved timer and recorder middlewares

    • timerMiddleware now populates request.Env["START_TIME"]
    • recorderMiddleware now records request.Env["BYTES_WRITTEN"]
    • โœ… tests have been added to both

    JSONP middleware

    This is a new public middleware that can be instantiated like this:

    handler := rest.ResourceHandler{ PreRoutingMiddlewares: []rest.Middleware{ &rest.JsonpMiddleware{ CallbackNameKey: "cb", }, }, }
    

    ๐Ÿ‘€ See the complete example here: https://github.com/ant0ine/go-json-rest#jsonp

    ๐Ÿ‘‰ Make the gzip middleware support streaming responses

    The gzip Writer is now instantiated once per response, allowing multiple calls to response.Write() or response.WriteJson().
    ๐Ÿ‘€ See the streaming example here: https://github.com/ant0ine/go-json-rest#streaming