« Back to home

Go-Json-Rest Version 3.0.0 Release Notes

Posted on

See Go-Json-Rest project on Github

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.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