Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(deps): update module github.com/kataras/iris/v12 to v12.2.0-alpha3 #456

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Sep 22, 2021

WhiteSource Renovate

This PR contains the following updates:

Package Type Update Change
github.com/kataras/iris/v12 require patch v12.2.0-alpha2 -> v12.2.0-alpha3

Release Notes

kataras/iris

v12.2.0-alpha3

Compare Source

Next (currently v12.2.0-alpha3)

This release introduces new features and some breaking changes.
The codebase for Dependency Injection, Internationalization and localization and more have been simplified a lot (fewer LOCs and easier to read and follow up).

Fixes and Improvements

  • Replace json-iterator with go-json as requested at #​1818.

  • New iris.IsErrEmptyJSON(err) bool which reports whether the given "err" is caused by a
    Context.ReadJSON call when the request body didn't start with { (or it was totally empty).

Example Code:

func handler(ctx iris.Context) {
    var opts SearchOptions
    if err := ctx.ReadJSON(&opts); err != nil && !iris.IsErrEmptyJSON(err) {
        ctx.StopWithJSON(iris.StatusBadRequest, iris.Map{"message": "unable to parse body"})
        return
    }

    // [...continue with default values of "opts" struct if the client didn't provide some]
}

That means that the client can optionally set a JSON body.

  • New APIContainer.EnableStrictMode(bool) to disable automatic payload binding and panic on missing dependencies for exported struct'sfields or function's input parameters on MVC controller or hero function or PartyConfigurator.

  • New Party.PartyConfigure(relativePath string, partyReg ...PartyConfigurator) Party helper, registers a children Party like Party and PartyFunc but instead it accepts a structure value which may contain one or more of the dependencies registered by RegisterDependency or ConfigureContainer().RegisterDependency methods and fills the unset/zero exported struct's fields respectfully (useful when the api's dependencies amount are too much to pass on a function).

  • New feature: add the ability to set custom error handlers on path type parameters errors (existing or custom ones). Example Code:

app.Macros().Get("uuid").HandleError(func(ctx iris.Context, paramIndex int, err error) {
    ctx.StatusCode(iris.StatusBadRequest)

    param := ctx.Params().GetEntryAt(paramIndex)
    ctx.JSON(iris.Map{
        "error":     err.Error(),
        "message":   "invalid path parameter",
        "parameter": param.Key,
        "value":     param.ValueRaw,
    })
})

app.Get("/users/{id:uuid}", getUser)
  • Improve the performance and fix :int, :int8, :int16, :int32, :int64, :uint, :uint8, :uint16, :uint32, :uint64 path type parameters couldn't accept a positive number written with the plus symbol or with a leading zeroes, e.g. +42 and 021.

  • The iris.WithEmptyFormError option is respected on context.ReadQuery method too, as requested at #​1727. Example comments were updated.

  • New httptest.Strict option setter to enable the httpexpect.RequireReporter instead of the default `httpexpect.AssetReporter. Use that to enable complete test failure on the first error. As requested at: #​1722.

  • New uuid builtin path parameter type. Example:

// +------------------------+
// | {param:uuid}           |
// +------------------------+
// UUIDv4 (and v1) path parameter validation.

// http://localhost:8080/user/bb4f33e4-dc08-40d8-9f2b-e8b2bb615c0e -> OK
// http://localhost:8080/user/dsadsa-invalid-uuid                  -> NOT FOUND
app.Get("/user/{id:uuid}", func(ctx iris.Context) {
    id := ctx.Params().Get("id")
    ctx.WriteString(id)
})
  • New Configuration.KeepAlive and iris.WithKeepAlive(time.Duration) Configurator added as helpers to start the server using a tcp listener featured with keep-alive.

  • New DirOptions.ShowHidden bool is added by @​tuhao1020 at PR #​1717 to show or hide the hidden files when ShowList is set to true.

  • New Context.ReadJSONStream method and JSONReader options for Context.ReadJSON and Context.ReadJSONStream, see the example.

  • New FallbackView feature, per-party or per handler chain. Example can be found at: _examples/view/fallback.

    app.FallbackView(iris.FallbackViewFunc(func(ctx iris.Context, err iris.ErrViewNotExist) error {
        // err.Name is the previous template name.
        // err.IsLayout reports whether the failure came from the layout template.
        // err.Data is the template data provided to the previous View call.
        // [...custom logic e.g. ctx.View("fallback.html", err.Data)]
        return err
    }))
  • New versioning.Aliases middleware and up to 80% faster version resolve. Example Code:
app := iris.New()

api := app.Party("/api")
api.Use(Aliases(map[string]string{
    versioning.Empty: "1", // when no version was provided by the client.
    "beta": "4.0.0",
    "stage": "5.0.0-alpha"
}))

v1 := NewGroup(api, ">=1.0.0 <2.0.0")
v1.Get/Post...

v4 := NewGroup(api, ">=4.0.0 <5.0.0")
v4.Get/Post...

stage := NewGroup(api, "5.0.0-alpha")
stage.Get/Post...
  • New Basic Authentication middleware. Its Default function has not changed, however, the rest, e.g. New contains breaking changes as the new middleware features new functionalities.

  • Add iris.DirOptions.SPA bool field to allow Single Page Applications under a file server.

  • A generic User interface, see the Context.SetUser/User methods in the New Context Methods section for more. In-short, the basicauth middleware's stored user can now be retrieved through Context.User() which provides more information than the native ctx.Request().BasicAuth() method one. Third-party authentication middleware creators can benefit of these two methods, plus the Logout below.

  • A Context.Logout method is added, can be used to invalidate basicauth or jwt client credentials.

  • Add the ability to share functions between handlers chain and add an example on sharing Go structures (aka services).

  • Add the new Party.UseOnce method to the *Route

  • Add a new *Route.RemoveHandler(...interface{}) int and Party.RemoveHandler(...interface{}) Party methods, delete a handler based on its name or the handler pc function.

func middleware(ctx iris.Context) {
    // [...]
}

func main() {
    app := iris.New()

    // Register the middleware to all matched routes.
    app.Use(middleware)

    // Handlers = middleware, other
    app.Get("/", index)

    // Handlers = other
    app.Get("/other", other).RemoveHandler(middleware)
}
  • Redis Driver is now based on the go-redis module. Radix and redigo removed entirely. Sessions are now stored in hashes which fixes issue #​1610. The only breaking change on default configuration is that the redis.Config.Delim option was removed. The redis sessions database driver is now defaults to the &redis.GoRedisDriver{}. End-developers can implement their own implementations too. The Database#Close is now automatically called on interrupt signals, no need to register it by yourself.

  • Add builtin support for i18n pluralization. Please check out the following yaml locale example to see an overview of the supported formats.

  • Fix #​1650

  • Fix #​1649

  • Fix #​1648

  • Fix #​1641

  • Add Party.SetRoutesNoLog(disable bool) Party to disable (the new) verbose logging of next routes.

  • Add mvc.Application.SetControllersNoLog(disable bool) *mvc.Application to disable (the new) verbose logging of next controllers. As requested at #​1630.

  • Fix #​1621 and add a new cache.WithKey to customize the cached entry key.

  • Add a Response() *http.Response to the Response Recorder.

  • Fix Response Recorder Flush when transfer-encoding is chunked.

  • Fix Response Recorder Clone concurrent access afterwards.

  • Add a ParseTemplate method on view engines to manually parse and add a template from a text as requested. Examples.

  • Full http.FileSystem interface support for all view engines as requested. The first argument of the functions(HTML, Blocks, Pug, Amber, Ace, Jet, Django, Handlebars) can now be either a directory of string type (like before) or a value which completes the http.FileSystem interface. The .Binary method of all view engines was removed: pass the go-bindata's latest version AssetFile() exported function as the first argument instead of string.

  • Add Route.ExcludeSitemap() *Route to exclude a route from sitemap as requested in chat, also offline routes are excluded automatically now.

  • Improved tracing (with app.Logger().SetLevel("debug")) for routes. Screens:

DBUG Routes (1)

DBUG routes 1

DBUG Routes (2)

DBUG routes 2

DBUG Routes (3)

DBUG routes with Controllers

MVC: HTTP Error Handler Method

RedirectMatch: # REDIRECT_CODE_DIGITS | PATTERN_REGEX | TARGET_REPL

Configuration

📅 Schedule: At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box.

This PR has been generated by WhiteSource Renovate. View repository job log here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant