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

@@ -6,6 +6,7 @@ import (
"github.com/kataras/iris/v12/context"
"github.com/google/uuid"
"github.com/kataras/golog"
)
const (
@@ -16,6 +17,9 @@ const (
type (
// Config is the configuration for sessions. Please read it before using sessions.
Config struct {
// Logger instance for sessions usage, e.g. { Logger: app.Logger() }.
// Defauls to a child of "sessions" of the latest Iris Application's main Logger.
Logger *golog.Logger
// Cookie string, the session's client cookie name, for example: "mysessionid"
//
// Defaults to "irissessionid".
@@ -65,6 +69,10 @@ type (
// Validate corrects missing fields configuration fields and returns the right configuration
func (c Config) Validate() Config {
if c.Logger == nil {
c.Logger = context.DefaultLogger("sessions")
}
if c.Cookie == "" {
c.Cookie = DefaultCookieName
}