minor improvement of the previous commit

This commit is contained in:
Gerasimos (Makis) Maropoulos 2021-02-17 16:57:19 +02:00
parent cbf70a7bcf
commit f34703e3cf
No known key found for this signature in database
GPG Key ID: A771A828097B36C7
3 changed files with 10 additions and 4 deletions

View File

@ -28,7 +28,7 @@ The codebase for Dependency Injection, Internationalization and localization and
## Fixes and Improvements
- New `PartyConfigure(relativePath string, partyReg PartyConfigurator) Party` helper, registers a children Party like `Party` and `PartyFunc` but instead it accepts a structure value (useful when the api's dependencies amount are too much to pass on a function).
- New `PartyConfigure(relativePath string, partyReg ...PartyConfigurator) Party` helper, registers a children Party like `Party` and `PartyFunc` but instead it accepts a structure value (useful when the api's dependencies amount are too much to pass on a function).
- **New feature:** add the ability to set custom error handlers on path type parameters errors (existing or custom ones). Example Code:

View File

@ -870,8 +870,14 @@ type PartyConfigurator interface {
// router.Get("/{id:uuid}", api.getUser)
// [...]
// }
func (api *APIBuilder) PartyConfigure(relativePath string, partyReg PartyConfigurator) Party {
return api.PartyFunc(relativePath, partyReg.Configure)
func (api *APIBuilder) PartyConfigure(relativePath string, partyReg ...PartyConfigurator) Party {
child := api.Party(relativePath)
for _, p := range partyReg {
if p != nil {
p.Configure(child)
}
}
return child
}
// Subdomain returns a new party which is responsible to register routes to

View File

@ -99,7 +99,7 @@ type Party interface {
// router.Get("/{id:uuid}", api.getUser)
// [...]
// }
PartyConfigure(relativePath string, partyReg PartyConfigurator) Party
PartyConfigure(relativePath string, partyReg ...PartyConfigurator) Party
// Subdomain returns a new party which is responsible to register routes to
// this specific "subdomain".
//