lars v3.3.0 Release Notes

Release Date: 2016-08-24 // almost 6 years ago
  • What's New?

    • ⚡️ updated to use std lib context and new embedded http.Context new in Go 1.7 ( set it up a long time ago for this, just finally found time to implement )

    Don't worry, no breaking changes, Go 1.6 and earlier will still work as it always has.

    Special Note

    📦 I don't know if it was an oversight or just an assumption about how middleware would be used with Go 1.7's new context integration into the *http.Request but there are a few quirks. As you know lars handles multiple handler types, including the native handler, this functionality is possible because of the way lar handles the middleware; lars does not chain the middleware in the normal way, but rather calles each in sequence; because of this all you have to do is call c.Next() or it has already been wrapped to do so for you transparently. OK getting back to the point, if you are not using lars.Context to set the context information you will have to set the request object so that the information gets back to the calling package. eg.

    // because 'r' is a copy of a pointer to allow the information to get// back to the caller, need to set the value of 'r' as below with '\*r'func(w http.ResponseWriter, r \*http.Request) { \*r = \*r.WithContext(context.WithValue(r.Context(), 0, "testval1")) }
    

    this is not an issue specific to lars, but a quirk of the way context is tied to the http.Request object.