mirror of
https://github.com/kataras/iris.git
synced 2026-01-04 18:57:03 +00:00
update code for go version 1.24
This commit is contained in:
@@ -10,6 +10,9 @@ import (
|
||||
|
||||
"github.com/kataras/iris/v12/core/router"
|
||||
"github.com/kataras/iris/v12/macro"
|
||||
|
||||
"golang.org/x/text/cases"
|
||||
"golang.org/x/text/language"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -137,8 +140,8 @@ func parseMethod(macros *macro.Macros, fn reflect.Method, skipper func(string) b
|
||||
}
|
||||
|
||||
func methodTitle(httpMethod string) string {
|
||||
httpMethodFuncName := strings.Title(strings.ToLower(httpMethod))
|
||||
return httpMethodFuncName
|
||||
caser := cases.Title(language.English)
|
||||
return caser.String(strings.ToLower(httpMethod))
|
||||
}
|
||||
|
||||
var errSkip = errors.New("skip")
|
||||
|
||||
@@ -19,7 +19,7 @@ type testController struct {
|
||||
}
|
||||
|
||||
var writeMethod = func(ctx *context.Context) {
|
||||
ctx.Writef(ctx.Method())
|
||||
ctx.WriteString(ctx.Method())
|
||||
}
|
||||
|
||||
func (c *testController) Get() {
|
||||
@@ -108,15 +108,15 @@ func (c *testControllerBeginAndEndRequestFunc) BeginRequest(ctx *context.Context
|
||||
|
||||
// called after every method (Get() or Post()).
|
||||
func (c *testControllerBeginAndEndRequestFunc) EndRequest(ctx *context.Context) {
|
||||
ctx.Writef("done") // append "done" to the response
|
||||
ctx.WriteString("done") // append "done" to the response
|
||||
}
|
||||
|
||||
func (c *testControllerBeginAndEndRequestFunc) Get() {
|
||||
c.Ctx.Writef(c.Username)
|
||||
c.Ctx.WriteString(c.Username)
|
||||
}
|
||||
|
||||
func (c *testControllerBeginAndEndRequestFunc) Post() {
|
||||
c.Ctx.Writef(c.Username)
|
||||
c.Ctx.WriteString(c.Username)
|
||||
}
|
||||
|
||||
func TestControllerBeginAndEndRequestFunc(t *testing.T) {
|
||||
@@ -230,7 +230,7 @@ func writeModels(ctx *context.Context, names ...string) {
|
||||
return
|
||||
}
|
||||
|
||||
ctx.Writef(model.Username)
|
||||
ctx.WriteString(model.Username)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,7 +269,7 @@ type testControllerBindStruct struct {
|
||||
}
|
||||
|
||||
func (t *testControllerBindStruct) Get() {
|
||||
t.Ctx.Writef(t.TitlePointer.title + t.TitleValue.title + t.Other)
|
||||
t.Ctx.WriteString(t.TitlePointer.title + t.TitleValue.title + t.Other)
|
||||
}
|
||||
|
||||
// test if context can be binded to the controller's function
|
||||
@@ -291,7 +291,7 @@ func (t *testControllerBindDeep) BeforeActivation(b BeforeActivation) {
|
||||
|
||||
func (t *testControllerBindDeep) Get() {
|
||||
// t.testControllerBindStruct.Get()
|
||||
t.Ctx.Writef(t.TitlePointer.title + t.TitleValue.title + t.Other)
|
||||
t.Ctx.WriteString(t.TitlePointer.title + t.TitleValue.title + t.Other)
|
||||
}
|
||||
|
||||
func (t *testControllerBindDeep) Post(v testCustomStruct) string {
|
||||
@@ -338,9 +338,9 @@ func (c *testCtrl0) Get() string {
|
||||
|
||||
func (c *testCtrl0) EndRequest(ctx *context.Context) {
|
||||
if c.TitlePointer == nil {
|
||||
ctx.Writef("\nTitlePointer is nil!\n")
|
||||
ctx.WriteString("\nTitlePointer is nil!\n")
|
||||
} else {
|
||||
ctx.Writef(c.TitlePointer.title)
|
||||
ctx.WriteString(c.TitlePointer.title)
|
||||
}
|
||||
|
||||
// should be the same as `.testCtrl000.testCtrl0000.EndRequest(ctx)`
|
||||
|
||||
Reference in New Issue
Block a user