1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-24 20:35:59 +00:00

add GetDomain and SetCookieKVExpiration patch functions to the iris.Patches

This commit is contained in:
Gerasimos (Makis) Maropoulos
2022-09-21 22:21:14 +03:00
parent 0a4927f6df
commit 5bc0796548
8 changed files with 21 additions and 8 deletions

View File

@@ -6,6 +6,7 @@ import (
"path"
"regexp"
"strings"
"time"
"github.com/kataras/iris/v12/cache"
"github.com/kataras/iris/v12/context"
@@ -792,6 +793,18 @@ func (cp *ContextPatches) Writers() *ContextWriterPatches {
return cp.writers
}
// GetDomain modifies the way a domain is fetched from `Context#Domain` method,
// which is used on subdomain redirect feature, i18n's language cookie for subdomain sharing
// and the rewrite middleware.
func (cp *ContextPatches) GetDomain(patchFunc func(hostport string) string) {
context.GetDomain = patchFunc
}
// SetCookieKVExpiration modifies the default cookie expiration time on `Context#SetCookieKV` method.
func (cp *ContextPatches) SetCookieKVExpiration(patch time.Duration) {
context.SetCookieKVExpiration = patch
}
// ContextWriterPatches features the context's writers patches.
type ContextWriterPatches struct{}