Documentation
¶
Index ¶
- Variables
- func AddOneMonthFallbackToLastDayOfMonth(date time.Time) time.Time
- func CloseToNow(t time.Time) bool
- func ConvertTimeToTimestampPtr(input *time.Time) *timestamppb.Timestamp
- func ConvertToUTC(datetimeStr string) (time.Time, error)
- func Decode(input map[string]any, result any) error
- func EndOfDayInUTC(t time.Time) time.Time
- func ExtractDomain(input string) string
- func FirstTimeOfMonth(year, month int) time.Time
- func GenerateEventID() string
- func GenerateNanoID(length int) string
- func GenerateNanoIDWithPrefix(prefix string, length int) string
- func GetCurrentTimeInTimeZone(timezone string) time.Time
- func GetDomainWithoutTLD(domain string) string
- func GetTenantFromContext(ctx context.Context) string
- func GetUserEmailFromContext(ctx context.Context) string
- func GetUserIdFromContext(ctx context.Context) string
- func IsAfter(t1, t2 *time.Time) bool
- func IsEndOfMonth(t time.Time) bool
- func IsEqualTimePtr(t1, t2 *time.Time) bool
- func IsInFuture(timestamp time.Time) bool
- func IsLowerAlphanumeric(s string) bool
- func IsStringInSlice(s string, slice []string) bool
- func IsSuspiciousURL(url string) bool
- func IsValidDomain(input string) bool
- func IsValidTLD(input string) bool
- func LastDayOfMonth(year, month int) time.Time
- func LastTimeOfMonth(year, month int) time.Time
- func MatchPattern(s, pattern string) bool
- func MiddleTimeOfMonth(year, month int) time.Time
- func NormalizeUrlPath(s string) string
- func Now() time.Time
- func NowIfZero(t time.Time) time.Time
- func NowPtr() *time.Time
- func SanitizeUTF8(input string) string
- func SetAppSourceInContext(ctx context.Context, appSource string) context.Context
- func SetTenantInContext(ctx context.Context, tenant string) context.Context
- func SetUserIdInContext(ctx context.Context, userId string) context.Context
- func SortUrlsByLength(urls []string) []string
- func StartOfDayInUTC(t time.Time) time.Time
- func StripUrlToBasePath(s string) string
- func TimeOrNowFromPtr(t *time.Time) time.Time
- func TimePtr(t time.Time) *time.Time
- func TimestampProtoToTime(pbTime *timestamppb.Timestamp) time.Time
- func TimestampProtoToTimePtr(pbTime *timestamppb.Timestamp) *time.Time
- func ToDate(t time.Time) time.Time
- func ToDateAsAny(t *time.Time) interface{}
- func ToDatePtr(t *time.Time) *time.Time
- func ToHookFunc() mapstructure.DecodeHookFunc
- func Today() time.Time
- func URLContainsRandomString(s string) bool
- func UnmarshalDateTime(input string) (*time.Time, error)
- func ValidateTenant(ctx context.Context) error
- func ValidateUserId(ctx context.Context) error
- func WithContext(customContext *CustomContext, next http.Handler) http.Handler
- func WithCustomContext(ctx context.Context, customContext *CustomContext) context.Context
- func WithCustomContextFromGinRequest(c *gin.Context) context.Context
- func WithCustomContextFromNats(ctx context.Context, msg *nats.Msg) context.Context
- func WithTenant(ctx context.Context, tenant string) context.Context
- func WithTenantContext(ctx context.Context, tenant string) context.Context
- func WithUserId(ctx context.Context, userID string) context.Context
- func ZeroTime() time.Time
- type CustomContext
- type URLComponents
- type UserAgent
- type YearMonth
Constants ¶
This section is empty.
Variables ¶
View Source
var TenantHeaders = []string{
"X-TENANT",
"x-tenant",
"X-Tenant",
"tenant",
"Tenant",
"TENANT",
"tenantname",
"TenantName",
"tenantName",
"TENANTNAME",
}
TenantHeaders is a list of possible header names for tenant identification
View Source
var UserIdHeaders = []string{
"X-USER-ID",
"X-USERID",
"X-User-Id",
"X-UserId",
"X-User-ID",
"X-Userid",
"x-user-id",
"User-ID",
"UserId",
"Userid",
"USERID",
}
Functions ¶
func CloseToNow ¶
func ConvertTimeToTimestampPtr ¶
func ConvertTimeToTimestampPtr(input *time.Time) *timestamppb.Timestamp
func ExtractDomain ¶ added in v0.0.35
func FirstTimeOfMonth ¶
func GenerateEventID ¶
func GenerateEventID() string
func GenerateNanoID ¶
func GetDomainWithoutTLD ¶ added in v0.0.36
GetDomainWithoutTLD returns everything before the last dot in the domain
func GetTenantFromContext ¶
func GetUserEmailFromContext ¶
func GetUserIdFromContext ¶
func IsAfter ¶
IsAfter compares two *time.Time, considering nil as far in the future. if both are nil return false
func IsEndOfMonth ¶
func IsEqualTimePtr ¶
IsEqualTimePtr compares two *time.Time values and returns true if both are nil or if both point to the same time.
func IsInFuture ¶
func IsLowerAlphanumeric ¶
func IsStringInSlice ¶ added in v0.0.35
func IsSuspiciousURL ¶
func IsValidDomain ¶ added in v0.0.36
func IsValidTLD ¶ added in v0.0.35
func LastDayOfMonth ¶
func LastTimeOfMonth ¶
func MatchPattern ¶ added in v0.0.80
MatchPattern checks if a string matches a given regex pattern
func MiddleTimeOfMonth ¶
func NormalizeUrlPath ¶
func SanitizeUTF8 ¶
func SetAppSourceInContext ¶
func SetTenantInContext ¶
func SetUserIdInContext ¶
func SortUrlsByLength ¶
func StripUrlToBasePath ¶
func TimestampProtoToTime ¶
func TimestampProtoToTime(pbTime *timestamppb.Timestamp) time.Time
func TimestampProtoToTimePtr ¶
func TimestampProtoToTimePtr(pbTime *timestamppb.Timestamp) *time.Time
func ToDateAsAny ¶
func ToHookFunc ¶
func ToHookFunc() mapstructure.DecodeHookFunc
func URLContainsRandomString ¶
func ValidateTenant ¶
func ValidateUserId ¶
func WithContext ¶
func WithContext(customContext *CustomContext, next http.Handler) http.Handler
func WithCustomContext ¶
func WithCustomContext(ctx context.Context, customContext *CustomContext) context.Context
func WithTenant ¶
WithTenant adds tenant to context
func WithTenantContext ¶
WithTenantContext creates a new context with the specified tenant
func WithUserId ¶
WithUserId adds user ID to context
Types ¶
type CustomContext ¶
func GetContext ¶
func GetContext(ctx context.Context) *CustomContext
type URLComponents ¶
type URLComponents struct {
URL string
Protocol string
Host string
Path string
PathSegments []string
QueryRaw string
QueryParams map[string][]string
Anchor string
}
func ParseURL ¶
func ParseURL(rawURL string) (*URLComponents, error)
type UserAgent ¶
type UserAgent struct {
Raw string
Browser string
BrowserVersion string
Engine string
EngineVersion string
OS string
OSVersion string
Device string
DeviceModel string
IsMobile bool
IsTablet bool
IsBot bool
IsWebView bool
SocialPlatform string
}
func ParseUserAgent ¶
ParseUserAgent parses a user agent string into structured information
Click to show internal directories.
Click to hide internal directories.