1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-18 02:17:05 +00:00

update jwt dependency and use the current Party if relative path is empty on PartyConfigure only

This commit is contained in:
Gerasimos (Makis) Maropoulos
2021-03-03 14:39:47 +02:00
parent fa81c596df
commit 89f02c6e87
5 changed files with 36 additions and 13 deletions

View File

@@ -873,14 +873,19 @@ type PartyConfigurator interface {
Configure(parent Party)
}
// PartyConfigure like `Party` and `PartyFunc` registers a new children Party but instead it accepts a struct value.
// It initializes a new children Party and executes the PartyConfigurator's Configure.
// Useful when the api's dependencies amount are too much to pass on a function.
// PartyConfigure like `Party` and `PartyFunc` registers a new children Party
// but instead it accepts a struct value which should implement the PartyConfigurator interface.
//
// As an exception, if the end-developer registered one or more dependencies upfront through
// PartyConfigure accepts the relative path of the child party
// (As an exception, if it's empty then all configurators are applied to the current Party)
// and one or more Party configurators and
// executes the PartyConfigurator's Configure method.
//
// If the end-developer registered one or more dependencies upfront through
// RegisterDependencies or ConfigureContainer.RegisterDependency methods
// and "p" is a pointer to a struct then try to bind the unset/zero exported fields
// to the registered dependencies, just like we do with Controllers.
// Useful when the api's dependencies amount are too much to pass on a function.
//
// Usage:
// app.PartyConfigure("/users", &api.UsersAPI{UserRepository: ..., ...})
@@ -894,7 +899,14 @@ type PartyConfigurator interface {
// app.RegisterDependency(userRepo, ...)
// app.PartyConfigure("/users", &api.UsersAPI{})
func (api *APIBuilder) PartyConfigure(relativePath string, partyReg ...PartyConfigurator) Party {
child := api.Party(relativePath)
var child Party
if relativePath == "" {
child = api
} else {
child = api.Party(relativePath)
}
for _, p := range partyReg {
if p == nil {
continue
@@ -908,9 +920,15 @@ func (api *APIBuilder) PartyConfigure(relativePath string, partyReg ...PartyConf
p.Configure(child)
}
return child
}
func (api *APIBuilder) configureParty(partyReg ...PartyConfigurator) Party {
return api
}
// Subdomain returns a new party which is responsible to register routes to
// this specific "subdomain".
//