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