Releases: ant0ine/go-json-rest
v3.3.2
Version 3.3.2 Release Notes
What's New in v3.3.2 ?
v3.3.1
Version 3.3.1 Release Notes
What's New in v3.3.1 ?
- Refactor/add unit tests
- Remove the ResourceHandler (v2 API) that was marked as deprecated a year ago.
- Start using the simplifications (gofmt -s)
- Minor documentation improvements
New third party Middlewares
Version 3.3.0 Release Notes
Version 3.3.0 Release Notes
What's New in v3.3.0 ?
- Include
charset=utf-8
in the JSON response Content-Type (See issue about Chrome) - Add the ability to customize the field name in the error response.
- Additional HTTP methods shortcuts (Thanks @sebest !)
- Add error is the parsed JSON payload is empty (Thanks @sebest !)
New third party Middlewares
v3.2.0
Version 3.2.0 Release Notes
What's New in v3.2.0 ?
- New shortcut methods to create Routes more easily:
Get(...), Post(...), Put(...), Delete(...)
. It also has the benefit to makegolint
happier. And&Route{...}
remains available for any other use case. - New Websocket example. (Thanks @wingyplus !)
- Security fix on the Jsonp Middleware. (Thanks @sebest !)
- Documentation improvements
v3.1.0
Version 3.1.0 Release Notes
What's New in v3.1.0 ?
- A new IfMiddleware that allows to conditionally execute a Middleware at runtime.
- Better error messages when Env variables are missing (Timer, AccessLogApache, and Status Middlewares updated)
- New Statsd example
- New JWT authentication example
- Improved code coverage
New Third party Middlewares
- JWT authentication Middleware by @StephanDollberg
- Statsd app monitoring Middleware
v3.0.0
Version 3 Release Notes
What's New in v3
- Public Middlewares. (12 included in the package)
- A new App interface. (the router being the provided App)
- A new Api object that manages the Middlewares and the App.
- Optional and interchangeable App/router.
Here is for instance the new minimal "Hello World!"
api := rest.NewApi()
api.Use(rest.DefaultDevStack...)
api.SetApp(rest.AppSimple(func(w rest.ResponseWriter, r *rest.Request) {
w.WriteJson(map[string]string{"Body": "Hello World!"})
}))
http.ListenAndServe(":8080", api.MakeHandler())
All 19 examples have been updated to use the new API. See here
Deprecating the ResourceHandler
V3 is about deprecating the ResourceHandler in favor of a new API that exposes the Middlewares. As a consequence, all the Middlewares are now public, and the new Api object helps putting them together as a stack. Some default stack configurations are offered. The router is now an App that sits on top of the stack of Middlewares. Which means that the router is no longer required to use Go-Json-Rest.
Design ideas and discussion See here
Migration guide See here
v2.1.0
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,
}
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