1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-17 09:57:01 +00:00

add a new Party.EnsureStaticBindings method - read HISTORY.md

This commit is contained in:
Gerasimos (Makis) Maropoulos
2022-03-12 12:32:27 +02:00
parent 7ab0f6fff5
commit 9cf6f9fa5e
6 changed files with 26 additions and 0 deletions

View File

@@ -53,6 +53,10 @@ type Container struct {
// set to true to disable that kind of behavior.
DisablePayloadAutoBinding bool
// DisableStructDynamicBindings if true panics on struct handler (controller)
// if at least one input binding depends on the request and not in a static structure.
DisableStructDynamicBindings bool
// DependencyMatcher holds the function that compares equality between
// a dependency with an input. Defaults to DefaultMatchDependencyFunc.
DependencyMatcher DependencyMatcher
@@ -249,6 +253,7 @@ func (c *Container) Clone() *Container {
copy(clonedDeps, c.Dependencies)
cloned.Dependencies = clonedDeps
cloned.DisablePayloadAutoBinding = c.DisablePayloadAutoBinding
cloned.DisableStructDynamicBindings = c.DisableStructDynamicBindings
cloned.MarkExportedFieldsAsRequired = c.MarkExportedFieldsAsRequired
cloned.resultHandlers = c.resultHandlers
// Reports are not cloned.

View File

@@ -71,6 +71,10 @@ func makeStruct(structPtr interface{}, c *Container, partyParamsCount int) *Stru
elem.FieldByIndex(b.Input.StructFieldIndex).Set(input)
} else if !b.Dependency.Static {
if c.DisableStructDynamicBindings {
panic(fmt.Sprintf("binder: DisableStructDynamicBindings setting is set to true: dynamic binding found: %s", b.String()))
}
singleton = false
}
}