mirror of
https://github.com/kataras/iris.git
synced 2025-12-17 09:57:01 +00:00
update dependencies
This commit is contained in:
@@ -105,7 +105,7 @@ type ControllerActivator struct {
|
||||
|
||||
// NameOf returns the package name + the struct type's name,
|
||||
// it's used to take the full name of an Controller, the `ControllerActivator#Name`.
|
||||
func NameOf(v interface{}) string {
|
||||
func NameOf(v any) string {
|
||||
elemTyp := indirectType(reflect.ValueOf(v).Type())
|
||||
|
||||
typName := elemTyp.Name()
|
||||
@@ -115,7 +115,7 @@ func NameOf(v interface{}) string {
|
||||
return fullname
|
||||
}
|
||||
|
||||
func newControllerActivator(app *Application, controller interface{}) *ControllerActivator {
|
||||
func newControllerActivator(app *Application, controller any) *ControllerActivator {
|
||||
if controller == nil {
|
||||
return nil
|
||||
}
|
||||
@@ -424,7 +424,7 @@ func (c *ControllerActivator) parseMethod(m reflect.Method) {
|
||||
c.Handle(httpMethod, httpPath, m.Name)
|
||||
}
|
||||
|
||||
func (c *ControllerActivator) logErrorf(format string, args ...interface{}) {
|
||||
func (c *ControllerActivator) logErrorf(format string, args ...any) {
|
||||
c.Router().Logger().Errorf(format, args...)
|
||||
}
|
||||
|
||||
|
||||
@@ -204,7 +204,7 @@ func TestControllerMethodResultTypes(t *testing.T) {
|
||||
ContentType("text/html", "utf-8").
|
||||
Body().IsEqual("<b>internal server error</b>")
|
||||
|
||||
expectedResultFromCustomStruct := map[string]interface{}{
|
||||
expectedResultFromCustomStruct := map[string]any{
|
||||
"name": "Iris",
|
||||
"age": 2,
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ type testControllerEndRequestAwareness struct {
|
||||
func (c *testControllerEndRequestAwareness) Get() {
|
||||
username := c.Ctx.Params().Get("username")
|
||||
c.Ctx.Values().Set(c.Ctx.Application().ConfigurationReadOnly().GetViewDataContextKey(),
|
||||
map[string]interface{}{
|
||||
map[string]any{
|
||||
"TestModel": Model{Username: username},
|
||||
"myModel": Model{Username: username + "2"},
|
||||
})
|
||||
|
||||
10
mvc/mvc.go
10
mvc/mvc.go
@@ -55,7 +55,7 @@ func newApp(subRouter router.Party, container *hero.Container) *Application {
|
||||
}
|
||||
|
||||
// See `hero.BuiltinDependencies` too, here we are registering dependencies per MVC Application.
|
||||
func registerBuiltinDependencies(container *hero.Container, deps ...interface{}) {
|
||||
func registerBuiltinDependencies(container *hero.Container, deps ...any) {
|
||||
for _, dep := range deps {
|
||||
depTyp := reflect.TypeOf(dep)
|
||||
for i, dependency := range container.Dependencies {
|
||||
@@ -164,7 +164,7 @@ func (app *Application) EnableStructDependents() *Application {
|
||||
// It returns this Application.
|
||||
//
|
||||
// Example: `.Register(loggerService{prefix: "dev"}, func(ctx iris.Context) User {...})`.
|
||||
func (app *Application) Register(dependencies ...interface{}) *Application {
|
||||
func (app *Application) Register(dependencies ...any) *Application {
|
||||
if len(dependencies) > 0 && len(app.container.Dependencies) == len(hero.BuiltinDependencies) && len(app.Controllers) > 0 {
|
||||
allControllerNamesSoFar := make([]string, len(app.Controllers))
|
||||
for i := range app.Controllers {
|
||||
@@ -259,7 +259,7 @@ var IgnoreEmbedded OptionFunc = func(c *ControllerActivator) {
|
||||
// e.g. Handle(controller, GRPC {Server: grpcServer, Strict: true})
|
||||
//
|
||||
// Examples at: https://github.com/kataras/iris/tree/main/_examples/mvc
|
||||
func (app *Application) Handle(controller interface{}, options ...Option) *Application {
|
||||
func (app *Application) Handle(controller any, options ...Option) *Application {
|
||||
c := app.handle(controller, options...)
|
||||
// Note: log on register-time, so they can catch any failures before build.
|
||||
if !app.controllersNoLog {
|
||||
@@ -276,7 +276,7 @@ func (app *Application) Handle(controller interface{}, options ...Option) *Appli
|
||||
// Note that a websocket controller is registered and ran under a specific connection connected to a namespace
|
||||
// and it cannot send HTTP responses on that state.
|
||||
// However all static and dynamic dependency injection features are working, as expected, like any regular MVC Controller.
|
||||
func (app *Application) HandleWebsocket(controller interface{}) *websocket.Struct {
|
||||
func (app *Application) HandleWebsocket(controller any) *websocket.Struct {
|
||||
c := app.handle(controller)
|
||||
c.markAsWebsocket()
|
||||
|
||||
@@ -305,7 +305,7 @@ func (app *Application) GetNamespaces() websocket.Namespaces {
|
||||
return websocket.JoinConnHandlers(app.websocketControllers...).GetNamespaces()
|
||||
}
|
||||
|
||||
func (app *Application) handle(controller interface{}, options ...Option) *ControllerActivator {
|
||||
func (app *Application) handle(controller any, options ...Option) *ControllerActivator {
|
||||
// initialize the controller's activator, nothing too magical so far.
|
||||
c := newControllerActivator(app, controller)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user