diff --git a/HISTORY.md b/HISTORY.md index 3a8fc9c4..307e4b65 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -723,7 +723,7 @@ Response: ## Breaking Changes -- Strict versions format on `versioning.NewGroup` is required. E.g. `"1"` is not valid anymore, you have to specify `"1.0.0"`. Example: `NewGroup(api, ">=1.0.0 <2.0.0")`. The [routing/versioning](_examples/routing/versioning) examples have been updated. +- The `versioning.NewMatcher` has been removed entirely in favor of `NewGroup`. Strict versions format on `versioning.NewGroup` is required. E.g. `"1"` is not valid anymore, you have to specify `"1.0.0"`. Example: `NewGroup(api, ">=1.0.0 <2.0.0")`. The [routing/versioning](_examples/routing/versioning) examples have been updated. - Now that `RegisterView` can be used to register different view engines per-Party, there is no need to support registering multiple engines under the same Party. The `app.RegisterView` now upserts the given Engine instead of append. You can now render templates **without file extension**, e.g. `index` instead of `index.ace`, both forms are valid now. - The `Context.ContentType` does not accept filenames to resolve the mime type anymore (caused issues with vendor-specific(vnd) MIME types). - The `Configuration.RemoteAddrPrivateSubnets.IPRange.Start and End` are now type of `string` instead of `net.IP`. The `WithRemoteAddrPrivateSubnet` option remains as it is, already accepts `string`s. diff --git a/_examples/routing/versioning/main.go b/_examples/routing/versioning/main.go index 221fcf5f..3e18aa7e 100644 --- a/_examples/routing/versioning/main.go +++ b/_examples/routing/versioning/main.go @@ -33,7 +33,7 @@ func main() { You can customize it by setting a version based on the request context: api.Use(func(ctx *context.Context) { if version := ctx.URLParam("version"); version != "" { - SetVersion(ctx, version) + versioning.SetVersion(ctx, version) } ctx.Next() @@ -48,6 +48,8 @@ func main() { // Create a new Group, which is a compatible Party, // based on version constraints. v1 := versioning.NewGroup(api, ">=1.0.0 <2.0.0") + // To mark an API version as deprecated use the Deprecated method. + // v1.Deprecated(versioning.DefaultDeprecationOptions) // Optionally, set custom view engine and path // for templates based on the version. diff --git a/versioning/group_test.go b/versioning/group_test.go index ee8726c2..8512bc16 100644 --- a/versioning/group_test.go +++ b/versioning/group_test.go @@ -8,10 +8,6 @@ import ( "github.com/kataras/iris/v12/versioning" ) -func notFoundHandler(ctx iris.Context) { - ctx.NotFound() -} - const ( v10Response = "v1.0 handler" v2Response = "v2.x handler" diff --git a/versioning/version.go b/versioning/version.go index a8084e4e..cf2adc87 100644 --- a/versioning/version.go +++ b/versioning/version.go @@ -244,7 +244,6 @@ func Handler(version string) context.Handler { if err != nil { return func(ctx *context.Context) { ctx.StopWithError(500, err) - return } }