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

add two new examples and share the app's specific logger instance with sessions databases and APIBuilder

This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-08-16 07:07:36 +03:00
parent ef7d365e81
commit 889b7942d3
23 changed files with 346 additions and 89 deletions

View File

@@ -15,6 +15,8 @@ import (
"github.com/kataras/iris/v12/hero"
"github.com/kataras/iris/v12/macro"
macroHandler "github.com/kataras/iris/v12/macro/handler"
"github.com/kataras/golog"
)
// MethodNone is a Virtual method
@@ -153,6 +155,8 @@ func overlapRoute(r *Route, next *Route) {
// APIBuilder the visible API for constructing the router
// and child routers.
type APIBuilder struct {
// the application logger.
logger *golog.Logger
// parent is the creator of this Party.
// It is nil on Root.
parent *APIBuilder // currently it's used only on UseRouter feature.
@@ -227,8 +231,9 @@ var (
// NewAPIBuilder creates & returns a new builder
// which is responsible to build the API and the router handler.
func NewAPIBuilder() *APIBuilder {
func NewAPIBuilder(logger *golog.Logger) *APIBuilder {
return &APIBuilder{
logger: logger,
parent: nil,
macros: macro.Defaults,
errors: errgroup.New("API Builder"),
@@ -240,6 +245,11 @@ func NewAPIBuilder() *APIBuilder {
}
}
// Logger returns the Application Logger.
func (api *APIBuilder) Logger() *golog.Logger {
return api.logger
}
// IsRoot reports whether this Party is the root Application's one.
// It will return false on all children Parties, no exception.
func (api *APIBuilder) IsRoot() bool {