mirror of
https://github.com/kataras/iris.git
synced 2025-03-14 08:16:28 +01:00
Update to 4.4.9
This commit is contained in:
parent
aa0003eb68
commit
14982891c5
|
@ -2,9 +2,13 @@
|
||||||
|
|
||||||
**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`.
|
**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.4.8 -> 4.4.9
|
||||||
|
|
||||||
|
- **FIX**: Previous CORS fix wasn't enough and produces error before server's startup[*](https://github.com/kataras/iris/issues/461) if many paths were trying to auto-register an `.OPTIONS` route, now this is fixed in combined with some improvements on the [cors middleware](https://github.com/iris-contrib/middleware/tree/master/cors) too.
|
||||||
|
|
||||||
## 4.4.7 -> 4.4.8
|
## 4.4.7 -> 4.4.8
|
||||||
|
|
||||||
- **NEW**: `BodyDecoder` gives the ability to set a custom decoder **per passed object** when `context.ReadJSON` and `context.ReadXML`
|
- **NEW**: `BodyDecoder` gives the ability to set a custom decoder **per passed object** when `context.ReadJSON` and `context.ReadXML`
|
||||||
|
|
||||||
```go
|
```go
|
||||||
// BodyDecoder is an interface which any struct can implement in order to customize the decode action
|
// BodyDecoder is an interface which any struct can implement in order to customize the decode action
|
||||||
|
@ -39,7 +43,7 @@ type BodyDecoder interface {
|
||||||
- **FIX**: CORS not worked for all http methods
|
- **FIX**: CORS not worked for all http methods
|
||||||
- **FIX**: Unexpected Party root's route slash when `DisablePathCorrection` is false(default), as reported [here](https://github.com/kataras/iris/issues/453)
|
- **FIX**: Unexpected Party root's route slash when `DisablePathCorrection` is false(default), as reported [here](https://github.com/kataras/iris/issues/453)
|
||||||
- **small fix**: DisablePathEscape not affects the uri string
|
- **small fix**: DisablePathEscape not affects the uri string
|
||||||
- **small fix**: when Path Correction on POST redirect to the GET instead of POST
|
- **small fix**: when Path Correction on POST redirect to the GET instead of POST
|
||||||
|
|
||||||
## 4.4.0 -> 4.4.1
|
## 4.4.0 -> 4.4.1
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
|
|
||||||
<a href="https://github.com/kataras/iris/releases"><img src="https://img.shields.io/badge/%20version%20-%204.4.8%20-blue.svg?style=flat-square" alt="Releases"></a>
|
<a href="https://github.com/kataras/iris/releases"><img src="https://img.shields.io/badge/%20version%20-%204.4.9%20-blue.svg?style=flat-square" alt="Releases"></a>
|
||||||
|
|
||||||
<a href="https://github.com/iris-contrib/examples"><img src="https://img.shields.io/badge/%20examples-repository-3362c2.svg?style=flat-square" alt="Examples"></a>
|
<a href="https://github.com/iris-contrib/examples"><img src="https://img.shields.io/badge/%20examples-repository-3362c2.svg?style=flat-square" alt="Examples"></a>
|
||||||
|
|
||||||
|
@ -870,7 +870,7 @@ I recommend writing your API tests using this new library, [httpexpect](https://
|
||||||
Versioning
|
Versioning
|
||||||
------------
|
------------
|
||||||
|
|
||||||
Current: **v4.4.8**
|
Current: **v4.4.9**
|
||||||
|
|
||||||
> Iris is an active project
|
> Iris is an active project
|
||||||
|
|
||||||
|
@ -906,7 +906,7 @@ This project is licensed under the [MIT License](LICENSE), Copyright (c) 2016 Ge
|
||||||
[Travis]: http://travis-ci.org/kataras/iris
|
[Travis]: http://travis-ci.org/kataras/iris
|
||||||
[License Widget]: https://img.shields.io/badge/license-MIT%20%20License%20-E91E63.svg?style=flat-square
|
[License Widget]: https://img.shields.io/badge/license-MIT%20%20License%20-E91E63.svg?style=flat-square
|
||||||
[License]: https://github.com/kataras/iris/blob/master/LICENSE
|
[License]: https://github.com/kataras/iris/blob/master/LICENSE
|
||||||
[Release Widget]: https://img.shields.io/badge/release-4.4.8%20-blue.svg?style=flat-square
|
[Release Widget]: https://img.shields.io/badge/release-4.4.9%20-blue.svg?style=flat-square
|
||||||
[Release]: https://github.com/kataras/iris/releases
|
[Release]: https://github.com/kataras/iris/releases
|
||||||
[Chat Widget]: https://img.shields.io/badge/community-chat%20-00BCD4.svg?style=flat-square
|
[Chat Widget]: https://img.shields.io/badge/community-chat%20-00BCD4.svg?style=flat-square
|
||||||
[Chat]: https://kataras.rocket.chat/channel/iris
|
[Chat]: https://kataras.rocket.chat/channel/iris
|
||||||
|
|
42
http.go
42
http.go
|
@ -1039,19 +1039,7 @@ func (mux *serveMux) register(method []byte, subdomain string, path string, midd
|
||||||
|
|
||||||
// build collects all routes info and adds them to the registry in order to be served from the request handler
|
// build collects all routes info and adds them to the registry in order to be served from the request handler
|
||||||
// this happens once when server is setting the mux's handler.
|
// this happens once when server is setting the mux's handler.
|
||||||
func (mux *serveMux) build() func(reqCtx *fasthttp.RequestCtx) string {
|
func (mux *serveMux) build() (getRequestPath func(*fasthttp.RequestCtx) string, methodEqual func([]byte, []byte) bool) {
|
||||||
|
|
||||||
// check for cors conflicts FIRST in order to put them in OPTIONS tree also
|
|
||||||
for i := range mux.lookups {
|
|
||||||
r := mux.lookups[i]
|
|
||||||
if r.hasCors() {
|
|
||||||
if exists := mux.lookup(r.path + r.subdomain); exists == nil || exists.Method() != MethodOptions {
|
|
||||||
// skip any already registed to OPTIONS, some users maybe do that manually, so we should be careful here, we do not catch custom names but that's fairly enough
|
|
||||||
mux.register(MethodOptionsBytes, r.subdomain, r.path, r.middleware)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sort.Sort(bySubdomain(mux.lookups))
|
sort.Sort(bySubdomain(mux.lookups))
|
||||||
|
|
||||||
|
@ -1067,7 +1055,7 @@ func (mux *serveMux) build() func(reqCtx *fasthttp.RequestCtx) string {
|
||||||
// I decide that it's better to explicit give subdomain and a path to it than registedPath(mysubdomain./something) now its: subdomain: mysubdomain., path: /something
|
// I decide that it's better to explicit give subdomain and a path to it than registedPath(mysubdomain./something) now its: subdomain: mysubdomain., path: /something
|
||||||
// we have different tree for each of subdomains, now you can use everything you can use with the normal paths ( before you couldn't set /any/*path)
|
// we have different tree for each of subdomains, now you can use everything you can use with the normal paths ( before you couldn't set /any/*path)
|
||||||
if err := tree.entry.add(r.path, r.middleware); err != nil {
|
if err := tree.entry.add(r.path, r.middleware); err != nil {
|
||||||
mux.logger.Panic(err.Error())
|
mux.logger.Panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if mp := tree.entry.paramsLen; mp > mux.maxParameters {
|
if mp := tree.entry.paramsLen; mp > mux.maxParameters {
|
||||||
|
@ -1076,7 +1064,7 @@ func (mux *serveMux) build() func(reqCtx *fasthttp.RequestCtx) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// optimize this once once, we could do that: context.RequestPath(mux.escapePath), but we lose some nanoseconds on if :)
|
// optimize this once once, we could do that: context.RequestPath(mux.escapePath), but we lose some nanoseconds on if :)
|
||||||
getRequestPath := func(reqCtx *fasthttp.RequestCtx) string {
|
getRequestPath = func(reqCtx *fasthttp.RequestCtx) string {
|
||||||
return utils.BytesToString(reqCtx.Path()) //string(ctx.Path()[:]) // a little bit of memory allocation, old method used: BytesToString, If I see the benchmarks get low I will change it back to old, but this way is safer.
|
return utils.BytesToString(reqCtx.Path()) //string(ctx.Path()[:]) // a little bit of memory allocation, old method used: BytesToString, If I see the benchmarks get low I will change it back to old, but this way is safer.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1084,7 +1072,23 @@ func (mux *serveMux) build() func(reqCtx *fasthttp.RequestCtx) string {
|
||||||
getRequestPath = func(reqCtx *fasthttp.RequestCtx) string { return utils.BytesToString(reqCtx.RequestURI()) }
|
getRequestPath = func(reqCtx *fasthttp.RequestCtx) string { return utils.BytesToString(reqCtx.RequestURI()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
return getRequestPath
|
methodEqual = func(reqMethod []byte, treeMethod []byte) bool {
|
||||||
|
return bytes.Equal(reqMethod, treeMethod)
|
||||||
|
}
|
||||||
|
// check for cors conflicts FIRST in order to put them in OPTIONS tree also
|
||||||
|
for i := range mux.lookups {
|
||||||
|
r := mux.lookups[i]
|
||||||
|
if r.hasCors() {
|
||||||
|
// cors middleware is updated also, ref: https://github.com/kataras/iris/issues/461
|
||||||
|
methodEqual = func(reqMethod []byte, treeMethod []byte) bool {
|
||||||
|
// preflights
|
||||||
|
return bytes.Equal(reqMethod, MethodOptionsBytes) || bytes.Equal(reqMethod, treeMethod)
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1101,15 +1105,16 @@ func (mux *serveMux) lookup(routeName string) *route {
|
||||||
func (mux *serveMux) BuildHandler() HandlerFunc {
|
func (mux *serveMux) BuildHandler() HandlerFunc {
|
||||||
|
|
||||||
// initialize the router once
|
// initialize the router once
|
||||||
getRequestPath := mux.build()
|
getRequestPath, methodEqual := mux.build()
|
||||||
|
|
||||||
return func(context *Context) {
|
return func(context *Context) {
|
||||||
routePath := getRequestPath(context.RequestCtx)
|
routePath := getRequestPath(context.RequestCtx)
|
||||||
for i := range mux.garden {
|
for i := range mux.garden {
|
||||||
tree := mux.garden[i]
|
tree := mux.garden[i]
|
||||||
if !bytes.Equal(tree.method, context.Method()) {
|
if !methodEqual(context.Method(), tree.method) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if mux.hosts && tree.subdomain != "" {
|
if mux.hosts && tree.subdomain != "" {
|
||||||
// context.VirtualHost() is a slow method because it makes string.Replaces but user can understand that if subdomain then server will have some nano/or/milleseconds performance cost
|
// context.VirtualHost() is a slow method because it makes string.Replaces but user can understand that if subdomain then server will have some nano/or/milleseconds performance cost
|
||||||
requestHost := context.VirtualHostname()
|
requestHost := context.VirtualHostname()
|
||||||
|
@ -1123,7 +1128,6 @@ func (mux *serveMux) BuildHandler() HandlerFunc {
|
||||||
// so the host must be api.iris-go.com:8080
|
// so the host must be api.iris-go.com:8080
|
||||||
if tree.subdomain+mux.hostname != requestHost {
|
if tree.subdomain+mux.hostname != requestHost {
|
||||||
// go to the next tree, we have a subdomain but it is not the correct
|
// go to the next tree, we have a subdomain but it is not the correct
|
||||||
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user