mirror of
https://github.com/kataras/iris.git
synced 2025-01-23 02:31:04 +01:00
Fix https://github.com/iris-contrib/community-board/issues/10 and upgrade the minor version number
Former-commit-id: 02f6656aceb890217bfc19688d7f45224df274ec
This commit is contained in:
parent
6ff4500e3c
commit
e4df35e351
|
@ -29,6 +29,11 @@ Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.co
|
|||
|
||||
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
|
||||
|
||||
# Mo, 12 June 2017 | v7.1.0
|
||||
|
||||
Fix [that](https://github.com/iris-contrib/community-board/issues/10).
|
||||
|
||||
|
||||
# Su, 11 June 2017 | v7.0.5
|
||||
|
||||
Iris now supports static paths and dynamic paths for the same path prefix with zero performance cost:
|
||||
|
|
|
@ -6,7 +6,7 @@ A fast, cross-platform and efficient web framework with robust set of well-desig
|
|||
[![Report card](https://img.shields.io/badge/report%20card%20-a%2B-F44336.svg?style=flat-square)](http://goreportcard.com/report/kataras/iris)
|
||||
[![Support forum](https://img.shields.io/badge/support-page-ec2eb4.svg?style=flat-square)](http://support.iris-go.com)
|
||||
[![Examples](https://img.shields.io/badge/howto-examples-3362c2.svg?style=flat-square)](https://github.com/kataras/iris/tree/master/_examples#table-of-contents)
|
||||
[![Godocs](https://img.shields.io/badge/7.0.5-%20documentation-5272B4.svg?style=flat-square)](https://godoc.org/github.com/kataras/iris)
|
||||
[![Godocs](https://img.shields.io/badge/7.1.0-%20documentation-5272B4.svg?style=flat-square)](https://godoc.org/github.com/kataras/iris)
|
||||
[![Chat](https://img.shields.io/badge/community-%20chat-00BCD4.svg?style=flat-square)](https://kataras.rocket.chat/channel/iris)
|
||||
[![Buy me a cup of coffee](https://img.shields.io/badge/support-%20open--source-F4A460.svg?logo=data:image%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDAwIDEwMDAiPjxwYXRoIGZpbGw9InJnYigyMjAsMjIwLDIyMCkiIGQ9Ik04ODYuNiwzMDUuM2MtNDUuNywyMDMuMS0xODcsMzEwLjMtNDA5LjYsMzEwLjNoLTc0LjFsLTUxLjUsMzI2LjloLTYybC0zLjIsMjEuMWMtMi4xLDE0LDguNiwyNi40LDIyLjYsMjYuNGgxNTguNWMxOC44LDAsMzQuNy0xMy42LDM3LjctMzIuMmwxLjUtOGwyOS45LTE4OS4zbDEuOS0xMC4zYzIuOS0xOC42LDE4LjktMzIuMiwzNy43LTMyLjJoMjMuNWMxNTMuNSwwLDI3My43LTYyLjQsMzA4LjktMjQyLjdDOTIxLjYsNDA2LjgsOTE2LjcsMzQ4LjYsODg2LjYsMzA1LjN6Ii8%2BPHBhdGggZmlsbD0icmdiKDIyMCwyMjAsMjIwKSIgZD0iTTc5MS45LDgzLjlDNzQ2LjUsMzIuMiw2NjQuNCwxMCw1NTkuNSwxMEgyNTVjLTIxLjQsMC0zOS44LDE1LjUtNDMuMSwzNi44TDg1LDg1MWMtMi41LDE1LjksOS44LDMwLjIsMjUuOCwzMC4ySDI5OWw0Ny4zLTI5OS42bC0xLjUsOS40YzMuMi0yMS4zLDIxLjQtMzYuOCw0Mi45LTM2LjhINDc3YzE3NS41LDAsMzEzLTcxLjIsMzUzLjItMjc3LjVjMS4yLTYuMSwyLjMtMTIuMSwzLjEtMTcuOEM4NDUuMSwxODIuOCw4MzMuMiwxMzAuOCw3OTEuOSw4My45TDc5MS45LDgzLjl6Ii8%2BPC9zdmc%2B)](https://github.com/kataras/iris#buy-me-a-cup-of-coffee)
|
||||
|
||||
|
@ -394,7 +394,7 @@ Besides the fact that we have a [community chat][Chat] for questions or reports
|
|||
Version
|
||||
------------
|
||||
|
||||
Current: **7.0.5**
|
||||
Current: **7.1.0**
|
||||
|
||||
Each new release is pushed to the master. It stays there until the next version. When a next version is released then the previous version goes to its own branch with `gopkg.in` as its import path (and its own vendor folder), in order to keep it working "for-ever".
|
||||
|
||||
|
|
|
@ -10,11 +10,11 @@ func main() {
|
|||
|
||||
// GET: http://localhost:8080
|
||||
app.Get("/", info)
|
||||
|
||||
// GET: http://localhost:8080/profile/kataras
|
||||
app.Get("/profile/{username:string}", info)
|
||||
// GET: http://localhost:8080/profile/backups/any/number/of/paths/here
|
||||
app.Get("/profile/backups/{filepath:path}", info)
|
||||
|
||||
// GET: http://localhost:8080/profile/kataras/backups/any/number/of/paths/here
|
||||
app.Get("/profile/{username:string}/backups/{filepath:path}", info)
|
||||
// Favicon
|
||||
|
||||
// GET: http://localhost:8080/favicon.ico
|
||||
|
@ -101,7 +101,7 @@ func main() {
|
|||
|
||||
// GET: http://localhost:8080/
|
||||
// GET: http://localhost:8080/profile/kataras
|
||||
// GET: http://localhost:8080/profile/backups/any/number/of/paths/here
|
||||
// GET: http://localhost:8080/profile/kataras/backups/any/number/of/paths/here
|
||||
|
||||
// GET: http://localhost:8080/users/help
|
||||
// GET: http://localhost:8080/users
|
||||
|
@ -113,7 +113,9 @@ func main() {
|
|||
// GET: http://admin.localhost:8080
|
||||
// GET: http://admin.localhost:8080/settings
|
||||
// GET: http://any_thing_here.localhost:8080
|
||||
app.Run(iris.Addr(":8080"))
|
||||
if err := app.Run(iris.Addr(":8080")); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func info(ctx context.Context) {
|
||||
|
|
|
@ -147,6 +147,7 @@ func (rb *APIBuilder) Handle(method string, registeredPath string, handlers ...c
|
|||
}
|
||||
// global
|
||||
rb.routes.register(r)
|
||||
|
||||
// per -party
|
||||
rb.apiRoutes = append(rb.apiRoutes, r)
|
||||
// should we remove the rb.apiRoutes on the .Party (new children party) ?, No, because the user maybe use this party later
|
||||
|
@ -163,6 +164,11 @@ func (rb *APIBuilder) Party(relativePath string, handlers ...context.Handler) Pa
|
|||
parentPath = parentPath[1:] // remove first slash
|
||||
}
|
||||
|
||||
// this is checked later on but for easier debug is better to do it here:
|
||||
if rb.relativePath[0] == '/' && relativePath[0] == '/' {
|
||||
parentPath = parentPath[1:] // remove first slash if parent ended with / and new one started with /.
|
||||
}
|
||||
|
||||
fullpath := parentPath + relativePath
|
||||
// append the parent's +child's handlers
|
||||
middleware := joinHandlers(rb.middleware, handlers)
|
||||
|
|
|
@ -60,7 +60,6 @@ func (h *routerHandler) addRoute(method, subdomain, path string, handlers contex
|
|||
t = &tree{Method: method, Subdomain: subdomain, Nodes: &n}
|
||||
h.trees = append(h.trees, t)
|
||||
}
|
||||
|
||||
return t.Nodes.Add(path, handlers)
|
||||
}
|
||||
|
||||
|
@ -99,7 +98,6 @@ func (h *routerHandler) Build(provider RoutesProvider) error {
|
|||
func (h *routerHandler) HandleRequest(ctx context.Context) {
|
||||
method := ctx.Method()
|
||||
path := ctx.Path()
|
||||
|
||||
if !ctx.Application().ConfigurationReadOnly().GetDisablePathCorrection() {
|
||||
|
||||
if len(path) > 1 && path[len(path)-1] == '/' {
|
||||
|
@ -165,7 +163,6 @@ func (h *routerHandler) HandleRequest(ctx context.Context) {
|
|||
continue
|
||||
}
|
||||
}
|
||||
|
||||
handlers := t.Nodes.Find(path, ctx.Params())
|
||||
if len(handlers) > 0 {
|
||||
ctx.Do(handlers)
|
||||
|
|
|
@ -183,6 +183,12 @@ func compileRoutePathAndHandlers(handlers context.Handlers, tmpl *macro.Template
|
|||
|
||||
func convertTmplToNodePath(tmpl *macro.Template) (string, error) {
|
||||
routePath := tmpl.Src
|
||||
if len(tmpl.Params) > 0 {
|
||||
if routePath[len(routePath)-1] == '/' {
|
||||
routePath = routePath[0 : len(routePath)-2] // remove the last "/" if macro syntax instead of underline's
|
||||
}
|
||||
}
|
||||
|
||||
// if it has started with {} and it's valid
|
||||
// then the tmpl.Params will be filled,
|
||||
// so no any further check needed
|
||||
|
@ -191,7 +197,6 @@ func convertTmplToNodePath(tmpl *macro.Template) (string, error) {
|
|||
if i != len(tmpl.Params)-1 {
|
||||
return "", errors.New("parameter type \"ParamTypePath\" should be putted to the very last of a path")
|
||||
}
|
||||
|
||||
routePath = strings.Replace(routePath, p.Src, WildcardParam(p.Name), 1)
|
||||
} else {
|
||||
routePath = strings.Replace(routePath, p.Src, Param(p.Name), 1)
|
||||
|
@ -210,13 +215,15 @@ func convertTmplToHandler(tmpl *macro.Template) context.Handler {
|
|||
// 1. if we don't have, then we don't need to add a handler before the main route's handler (as I said, no performance if macro is not really used)
|
||||
// 2. if we don't have any named params then we don't need a handler too.
|
||||
for _, p := range tmpl.Params {
|
||||
if len(p.Funcs) == 0 && (p.Type == ast.ParamTypeString || p.Type == ast.ParamTypePath) && p.ErrCode == http.StatusNotFound {
|
||||
if len(p.Funcs) == 0 && (p.Type == ast.ParamTypeUnExpected || p.Type == ast.ParamTypeString || p.Type == ast.ParamTypePath) && p.ErrCode == http.StatusNotFound {
|
||||
} else {
|
||||
// println("we need handler for: " + tmpl.Src)
|
||||
needMacroHandler = true
|
||||
}
|
||||
}
|
||||
|
||||
if !needMacroHandler {
|
||||
// println("we don't need handler for: " + tmpl.Src)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ func (nodes *Nodes) Add(path string, handlers context.Handlers) error {
|
|||
return err
|
||||
}
|
||||
// create a second, empty, dynamic parameter node without the last slash
|
||||
if nidx := idx + 1; len(path) < nidx {
|
||||
if nidx := idx + 1; len(path) > nidx {
|
||||
if err := nodes.add(path[:nidx], nil, nil, true); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -102,6 +102,12 @@ func newSubdomainDivider(sep string) unis.DividerFunc {
|
|||
subdomainDevider := unis.NewInvertOnFailureDivider(unis.NewDivider(sep))
|
||||
return func(fullpath string) (string, string) {
|
||||
subdomain, path := subdomainDevider.Divide(fullpath)
|
||||
if len(path) > 1 {
|
||||
if path[0] == '/' && path[1] == '/' {
|
||||
path = path[1:]
|
||||
}
|
||||
}
|
||||
|
||||
return subdomain, path //cleanPath(path)
|
||||
}
|
||||
}
|
||||
|
|
2
iris.go
2
iris.go
|
@ -41,7 +41,7 @@ const (
|
|||
// Version is the current version number of the Iris Web framework.
|
||||
//
|
||||
// Look https://github.com/kataras/iris#where-can-i-find-older-versions for older versions.
|
||||
Version = "7.0.5"
|
||||
Version = "7.1.0"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
@ -57,7 +57,7 @@ func (d *Database) Load(sid string) map[string]interface{} {
|
|||
func serialize(values map[string]interface{}) []byte {
|
||||
val, err := SerializeBytes(values)
|
||||
if err != nil {
|
||||
println("On redisstore.serialize: " + err.Error())
|
||||
return nil
|
||||
}
|
||||
|
||||
return val
|
||||
|
|
Loading…
Reference in New Issue
Block a user