1
0
mirror of https://github.com/kataras/iris.git synced 2026-02-28 05:26:00 +00:00

Update to 4.5.2

This commit is contained in:
Gerasimos Maropoulos
2016-10-11 22:35:12 +03:00
parent 40b000c20f
commit 9bce4e846a
7 changed files with 121 additions and 15 deletions

View File

@@ -2,6 +2,39 @@
**How to upgrade**: remove your `$GOPATH/src/github.com/kataras` folder, open your command-line and execute this command: `go get -u github.com/kataras/iris/iris`.
## 4.5.1 -> 4.5.2
- **Feature request**: I never though that it will be easier for users to catch 405 instead of simple 404, I though that will make your life harder, but it's requested by the Community [here](https://github.com/kataras/iris/issues/469), so I did my duty. Enable firing Status Method Not Allowed (405) with a simple configuration field: `iris.Config.FireMethodNotAllowed=true` or `iris.Set(iris.OptionFireMethodNotAllowed(true))` or `app := iris.New(iris.Configuration{FireMethodNotAllowed:true})`, a test example:
```go
func TestMuxFireMethodNotAllowed(t *testing.T) {
iris.Config.FireMethodNotAllowed = true // enable catching 405 errors
h := func(ctx *iris.Context) {
ctx.Write("%s", ctx.MethodString())
}
Iris.OnError(iris.StatusMethodNotAllowed, func(ctx *iris.Context) {
ctx.Write("Hello from my custom 405 page")
})
iris.Get("/mypath", h)
iris.Put("/mypath", h)
e := iris.Tester(t)
e.GET("/mypath").Expect().Status(StatusOK).Body().Equal("GET")
e.PUT("/mypath").Expect().Status(StatusOK).Body().Equal("PUT")
// this should fail with 405 and catch by the custom http error
e.POST("/mypath").Expect().Status(StatusMethodNotAllowed).Body().Equal("Hello from my custom 405 page")
iris.Close()
}
```
## 4.5.0 -> 4.5.1
- **NEW**: `PreBuild` plugin type, raises before `.Build`. Used by third-party plugins to register any runtime routes or make any changes to the iris main configuration, example of this usage is the [OAuth/OAuth2 Plugin](https://github.com/iris-contrib/plugin/tree/master/oauth).