All Versions
26
Latest Version
Avg Release Cycle
20 days
Latest Release
582 days ago

Changelog History
Page 3

  • v11.1.1 Changes

    January 19, 2019

    Fr, 11 January 2019 | v11.1.1

    ๐Ÿš€ Happy new year! This is a minor release, contains mostly bug fixes.

    ๐Ÿš€ Strage that we don't have major features in this release, right? Don't worry, I am not out of ideas (at least not yet!).
    I have some features in-mind but lately I do not have the time to humanize them for you due to my new position in Netdata Inc., so be patient and stay-tuned. Read the current changelog below:

    0๏ธโƒฃ session/redis: fix unused service config var. IdleTimeout witch was replaced by default values. #1140 (@d7561985)

    ๐Ÿ›  fix #1141 and #1142. 2bd7a8e88777766d1f4cac7562feec304112d2b1 (@kataras)

    ๐Ÿ›  fix cache corruption due to recorder reuse. #1146 (@Slamper)

    ๐Ÿ’ป add StatusTooEarly, compatible with: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/425#Browser_compatibility. 31b2913447aa9e41e16a3eb33eb0019427e15cea (@kataras)

    ๐Ÿ›  fix #1164. 701e8e46c20395f87fa34bf9fabd145074c7b78c (@kataras)

    ๐Ÿ›  context#ReadForm can skip unkown fields by IsErrPath(err), fixes: #1157. 1607bb5113568af6a34142f23bfa44903205b314 (@kataras)

    โšก๏ธ Doc updates:

    ๐Ÿ›  fix grammar and misspell. 5069e9afd8700d20dfd04cdc008efd671b5d0b40 (@kataras)

    ๐Ÿ›  fix link for httpexpect in README. #1148 (@drenel18)

    translate _examples/README.md into Chinese. #1156 (fduxiao)

    โž• add https://github.com/snowlyg/IrisApiProject to starter kits (Chinese). ea12533871253afc34e40e36ba658b51955ea82d

    โž• add https://github.com/yz124/superstar to starter kits (Chinese). 0e734ff8445f07482c28881347c1e564dc5aab9c

  • v11.1.0 Changes

    November 18, 2018

    Su, 18 November 2018 | v11.1.0

    PR: #1130

    ๐Ÿš€ This release contains a new feature for versioning your Iris APIs. The initial motivation and feature request came by #1129.

    ๐Ÿ“ฆ The versioning package provides semver versioning for your APIs. It implements all the suggestions written at api-guidelines and more.

    ๐Ÿ“ฆ The version comparison is done by the go-version package. It supports matching over patterns like ">= 1.0, < 3" and etc.

    ๐Ÿ”‹ Features

    • per route version matching, a normal iris handler with "switch" cases via Map for version => handler
    • ๐Ÿ—„ per group versioned routes and deprecation API
    • ๐Ÿ”– version matching like ">= 1.0, < 2.0" or just "2.0.1" and etc.
    • ๐Ÿ”– version not found handler (can be customized by simply adding the versioning.NotFound: customNotMatchVersionHandler on the Map)
    • ๐Ÿ”– version is retrieved from the "Accept" and "Accept-Version" headers (can be customized via middleware)
    • respond with "X-API-Version" header, if version found.
    • ๐Ÿ—„ deprecation options with customizable "X-API-Warn", "X-API-Deprecation-Date", "X-API-Deprecation-Info" headers via Deprecated wrapper.

    Get version

    Current request version is retrieved by versioning.GetVersion(ctx).

    0๏ธโƒฃ By default the GetVersion will try to read from:

    • Accept header, i.e Accept: "application/json; version=1.0"
    • Accept-Version header, i.e Accept-Version: "1.0"

    You can also set a custom version for a handler via a middleware by using the context's store values.
    For example:

    func(ctx iris.Context) { ctx.Values().Set(versioning.Key, ctx.URLParamDefault("version", "1.0")) ctx.Next() }
    

    Match version to handler

    The versioning.NewMatcher(versioning.Map) iris.Handler creates a single handler which decides what handler need to be executed based on the requested version.

    app := iris.New()// middleware for all versions.myMiddleware := func(ctx iris.Context) { // [...] ctx.Next() }myCustomNotVersionFound := func(ctx iris.Context) { ctx.StatusCode(404) ctx.Writef("%s version not found", versioning.GetVersion(ctx)) }userAPI := app.Party("/api/user") userAPI.Get("/", myMiddleware, versioning.NewMatcher(versioning.Map{ "1.0": sendHandler(v10Response), "\>= 2, \< 3": sendHandler(v2Response), versioning.NotFound: myCustomNotVersionFound, }))
    

    ๐Ÿ—„ Deprecation

    ๐Ÿ—„ Using the versioning.Deprecated(handler iris.Handler, options versioning.DeprecationOptions) iris.Handler function you can mark a specific handler version as deprecated.

    v10Handler := versioning.Deprecated(sendHandler(v10Response), versioning.DeprecationOptions{ // if empty defaults to: "WARNING! You are using a deprecated version of this API."WarnMessage stringDeprecationDate time.TimeDeprecationInfo string}) userAPI.Get("/", versioning.NewMatcher(versioning.Map{ "1.0": v10Handler, // [...]}))
    

    This will make the handler to send these headers to the client:

    • "X-API-Warn": options.WarnMessage
    • ๐Ÿ—„ "X-API-Deprecation-Date": context.FormatTime(ctx, options.DeprecationDate))
    • ๐Ÿ—„ "X-API-Deprecation-Info": options.DeprecationInfo

    ๐Ÿ—„ > versioning.DefaultDeprecationOptions can be passed instead if you don't care about Date and Info.

    Grouping routes by version

    Grouping routes by version is possible as well.

    Using the versioning.NewGroup(version string) *versioning.Group function you can create a group to register your versioned routes.
    The versioning.RegisterGroups(r iris.Party, versionNotFoundHandler iris.Handler, groups ...*versioning.Group) must be called in the end in order to register the routes to a specific Party.

    app := iris.New()userAPI := app.Party("/api/user")// [... static serving, middlewares and etc goes here].userAPIV10 := versioning.NewGroup("1.0") userAPIV10.Get("/", sendHandler(v10Response))userAPIV2 := versioning.NewGroup("\>= 2, \< 3") userAPIV2.Get("/", sendHandler(v2Response)) userAPIV2.Post("/", sendHandler(v2Response)) userAPIV2.Put("/other", sendHandler(v2Response)) versioning.RegisterGroups(userAPI, versioning.NotFoundHandler, userAPIV10, userAPIV2)
    

    A middleware can be registered to the actual iris.Party only, using the methods we learnt above, i.e by using the versioning.Match in order to detect what code/handler you want to be executed when "x" or no version is requested.

    ๐Ÿ—„ Deprecation for Group

    ๐Ÿ—„ Just call the Deprecated(versioning.DeprecationOptions) on the group you want to notify your API consumers that this specific version is deprecated.

    userAPIV10 := versioning.NewGroup("1.0").Deprecated(versioning.DefaultDeprecationOptions)
    

    Compare version manually from inside your handlers

    // reports if the "version" is matching to the "is".// the "is" can be a constraint like "\>= 1, \< 3".If(version string, is string) bool
    
    // same as `If` but expects a Context to read the requested version.Match(ctx iris.Context, expectedVersion string) bool
    
    app.Get("/api/user", func(ctx iris.Context) { if versioning.Match(ctx, "\>= 2.2.3") { // [logic for \>= 2.2.3 version of your handler goes here]return } })
    

    Example can be found here.

  • v11.0.3 Changes

    November 06, 2018
    • โž• add "part" html view engine's tmpl function: 15bb55d
    • โšก๏ธ update pug engine's vendor: c20bc3b
  • v11.0.2

    October 29, 2018
  • v10.7.1

    November 18, 2018