package main import ( "context" "time" "git.xeserv.us/xena/route/internal/database" ) type ctxKey int const ( startTimeKey ctxKey = iota tokenKey ) func withStartTime(ctx context.Context) context.Context { return context.WithValue(ctx, startTimeKey, time.Now()) } func getStartTime(ctx context.Context) (time.Time, bool) { t, ok := ctx.Value(startTimeKey).(time.Time) if !ok { return time.Time{}, false } return t, true } func withAuthToken(ctx context.Context, token database.Token) context.Context { return context.WithValue(ctx, tokenKey, token) } func getAuthToken(ctx context.Context) (database.Token, bool) { t, ok := ctx.Value(tokenKey).(database.Token) if !ok { return database.Token{}, false } return t, true }