mirror of
https://github.com/kataras/iris.git
synced 2025-12-24 05:17:03 +00:00
update to version 8.4.1 ❤️ https://github.com/kataras/iris/blob/master/HISTORY.md#th-07-september-2017--v841
Former-commit-id: 9e5f0a08049b83605aa847b8f51fb856427354a6
This commit is contained in:
@@ -53,6 +53,13 @@ func resolveCaller(p pathInfo) callerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
if p.ParamType == paramTypeBoolean {
|
||||
return func(ctx context.Context, f interface{}) {
|
||||
paramValue, _ := ctx.Params().GetBool(paramName)
|
||||
f.(func(bool))(paramValue)
|
||||
}
|
||||
}
|
||||
|
||||
// else it's string or path, both of them are simple strings.
|
||||
return func(ctx context.Context, f interface{}) {
|
||||
paramValue := ctx.Params().Get(paramName)
|
||||
|
||||
@@ -20,15 +20,17 @@ type pathInfo struct {
|
||||
}
|
||||
|
||||
const (
|
||||
paramTypeInt = "int"
|
||||
paramTypeLong = "long"
|
||||
paramTypeString = "string"
|
||||
paramTypePath = "path"
|
||||
paramTypeInt = "int"
|
||||
paramTypeLong = "long"
|
||||
paramTypeBoolean = "boolean"
|
||||
paramTypeString = "string"
|
||||
paramTypePath = "path"
|
||||
)
|
||||
|
||||
var macroTypes = map[string]string{
|
||||
"int": paramTypeInt,
|
||||
"int64": paramTypeLong,
|
||||
"bool": paramTypeBoolean,
|
||||
"string": paramTypeString,
|
||||
// there is "path" param type but it's being captured "on-air"
|
||||
// "file" param type is not supported by the current implementation, yet
|
||||
@@ -71,7 +73,7 @@ func resolveRelativePath(info FuncInfo) (p pathInfo, ok bool) {
|
||||
}
|
||||
}
|
||||
|
||||
// int and string are supported.
|
||||
// int, int64, bool and string are supported.
|
||||
// as there is no way to get the parameter name
|
||||
// we will use the "param" everywhere.
|
||||
suffix := fmt.Sprintf("/{%s:%s}", paramName, paramType)
|
||||
|
||||
@@ -444,15 +444,17 @@ func (c *testControllerRelPathFromFunc) EndRequest(ctx context.Context) {
|
||||
c.Controller.EndRequest(ctx)
|
||||
}
|
||||
|
||||
func (c *testControllerRelPathFromFunc) Get() {}
|
||||
func (c *testControllerRelPathFromFunc) Get() {}
|
||||
func (c *testControllerRelPathFromFunc) GetBy(int64) {}
|
||||
func (c *testControllerRelPathFromFunc) GetByWildcard(string) {}
|
||||
|
||||
func (c *testControllerRelPathFromFunc) GetLogin() {}
|
||||
func (c *testControllerRelPathFromFunc) PostLogin() {}
|
||||
|
||||
func (c *testControllerRelPathFromFunc) GetAdminLogin() {}
|
||||
func (c *testControllerRelPathFromFunc) PutSomethingIntoThis() {}
|
||||
func (c *testControllerRelPathFromFunc) GetBy(int64) {}
|
||||
func (c *testControllerRelPathFromFunc) GetAdminLogin() {}
|
||||
|
||||
func (c *testControllerRelPathFromFunc) GetByWildcard(string) {}
|
||||
func (c *testControllerRelPathFromFunc) PutSomethingIntoThis() {}
|
||||
func (c *testControllerRelPathFromFunc) GetSomethingBy(bool) {}
|
||||
|
||||
func TestControllerRelPathFromFunc(t *testing.T) {
|
||||
app := iris.New()
|
||||
@@ -461,6 +463,16 @@ func TestControllerRelPathFromFunc(t *testing.T) {
|
||||
e := httptest.New(t, app)
|
||||
e.GET("/").Expect().Status(httptest.StatusOK).
|
||||
Body().Equal("GET:/")
|
||||
|
||||
e.GET("/42").Expect().Status(httptest.StatusOK).
|
||||
Body().Equal("GET:/42")
|
||||
e.GET("/something/true").Expect().Status(httptest.StatusOK).
|
||||
Body().Equal("GET:/something/true")
|
||||
e.GET("/something/false").Expect().Status(httptest.StatusOK).
|
||||
Body().Equal("GET:/something/false")
|
||||
e.GET("/something/truee").Expect().Status(httptest.StatusNotFound)
|
||||
e.GET("/something/falsee").Expect().Status(httptest.StatusNotFound)
|
||||
|
||||
e.GET("/login").Expect().Status(httptest.StatusOK).
|
||||
Body().Equal("GET:/login")
|
||||
e.POST("/login").Expect().Status(httptest.StatusOK).
|
||||
|
||||
Reference in New Issue
Block a user