Documentation
¶
Index ¶
- func BuildBlocklistMiddleware(config BlocklistConfig) func(http.HandlerFunc) http.HandlerFunc
- func BuildCORSHandler(allowedSuffixes *DomainSuffixes) http.HandlerFunc
- func BuildCORSMiddleware(allowedSuffixes *DomainSuffixes) func(http.HandlerFunc) http.HandlerFunc
- func BuildRegisterUserVisitMiddleware(registerUserVisit app.RegisterUserVisit) func(http.HandlerFunc) http.HandlerFunc
- func ComposeMiddlewares(middlewares ...func(http.HandlerFunc) http.HandlerFunc) func(http.HandlerFunc) http.HandlerFunc
- func HistoryToRainbowHistoryData(history []domain.PlayerPIT) ([]byte, error)
- func IPHashKeyFunc(r *http.Request) string
- func MakeAnonymousLoginHandler(login app.AnonymousLogin, nowFunc func() time.Time, ...) (http.HandlerFunc, func())
- func MakeAuthRefreshHandler(refresh app.RefreshSession, nowFunc func() time.Time, ...) (http.HandlerFunc, func())
- func MakeGetAccountByUUIDHandler(getAccountByUUID app.GetAccountByUUID, registerUserVisit app.RegisterUserVisit, ...) (http.HandlerFunc, func())
- func MakeGetAccountByUsernameHandler(getAccountByUsername app.GetAccountByUsername, ...) (http.HandlerFunc, func())
- func MakeGetHistoryHandler(getHistory app.GetHistory, registerUserVisit app.RegisterUserVisit, ...) (http.HandlerFunc, func())
- func MakeGetPlayerDataHandler(getAndPersistPlayerWithCache app.GetAndPersistPlayerWithCache, ...) (http.HandlerFunc, func())
- func MakeGetPrestigesHandler(findMilestoneAchievements app.FindMilestoneAchievements, ...) (http.HandlerFunc, func())
- func MakeGetSessionAtHandler(getSessionAt app.GetSessionAt, registerUserVisit app.RegisterUserVisit, ...) (http.HandlerFunc, func())
- func MakeGetSessionsHandler(getPlayerPITs app.GetPlayerPITs, computeSessions app.ComputeSessions, ...) (http.HandlerFunc, func())
- func MakeGetTagsHandler(getTags app.GetTags, registerUserVisit app.RegisterUserVisit, ...) (http.HandlerFunc, func())
- func MakeGetWrappedHandler(getPlayerPITs app.GetPlayerPITs, computeSessions app.ComputeSessions, ...) (http.HandlerFunc, func())
- func MakePrismNoticesHandler(getPrismNotices app.GetPrismNotices, registerUserVisit app.RegisterUserVisit, ...) (http.HandlerFunc, func())
- func NewBearerAuthMiddleware(validate app.ValidateSession) func(http.HandlerFunc) http.HandlerFunc
- func NewRateLimitMiddleware(rateLimiter ratelimiting.RequestRateLimiter, onLimitExceeded http.HandlerFunc) func(http.HandlerFunc) http.HandlerFunc
- func NewReportingMetaMiddleware(port string) func(http.HandlerFunc) http.HandlerFunc
- func NewRequestLoggerMiddleware(logger *slog.Logger) func(next http.HandlerFunc) http.HandlerFunc
- func PlayerToPrismPlayerDataResponseData(player *domain.PlayerPIT) ([]byte, error)
- func PlayerToRainbowPlayerDataPITData(player *domain.PlayerPIT) ([]byte, error)
- func SessionsToRainbowSessionsData(sessions []domain.Session) ([]byte, error)
- func UserIDKeyFunc(r *http.Request) string
- type AuthContext
- type BlocklistConfig
- type Client
- type DomainSuffixes
- type HypixelAPIErrorResponse
- type IP
- type UserID
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildBlocklistMiddleware ¶
func BuildBlocklistMiddleware(config BlocklistConfig) func(http.HandlerFunc) http.HandlerFunc
func BuildCORSHandler ¶
func BuildCORSHandler(allowedSuffixes *DomainSuffixes) http.HandlerFunc
func BuildCORSMiddleware ¶
func BuildCORSMiddleware(allowedSuffixes *DomainSuffixes) func(http.HandlerFunc) http.HandlerFunc
func BuildRegisterUserVisitMiddleware ¶
func BuildRegisterUserVisitMiddleware(registerUserVisit app.RegisterUserVisit) func(http.HandlerFunc) http.HandlerFunc
func ComposeMiddlewares ¶
func ComposeMiddlewares(middlewares ...func(http.HandlerFunc) http.HandlerFunc) func(http.HandlerFunc) http.HandlerFunc
func IPHashKeyFunc ¶
func MakeAnonymousLoginHandler ¶
func MakeAnonymousLoginHandler( login app.AnonymousLogin, nowFunc func() time.Time, allowedOrigins *DomainSuffixes, rootLogger *slog.Logger, sentryMiddleware func(http.HandlerFunc) http.HandlerFunc, blocklistConfig BlocklistConfig, ) (http.HandlerFunc, func())
MakeAnonymousLoginHandler returns a handler for POST /v1/auth/anonymous/login. Body: { userId }. Response: a fresh session payload.
func MakeAuthRefreshHandler ¶
func MakeAuthRefreshHandler( refresh app.RefreshSession, nowFunc func() time.Time, allowedOrigins *DomainSuffixes, rootLogger *slog.Logger, sentryMiddleware func(http.HandlerFunc) http.HandlerFunc, blocklistConfig BlocklistConfig, ) (http.HandlerFunc, func())
MakeAuthRefreshHandler returns a handler for POST /v1/auth/refresh. Accepts a Bearer token (which may be past expires_at but within refresh_until). Tier-agnostic: the underlying use case branches on the stored session.
func MakeGetAccountByUUIDHandler ¶
func MakeGetAccountByUUIDHandler( getAccountByUUID app.GetAccountByUUID, registerUserVisit app.RegisterUserVisit, allowedOrigins *DomainSuffixes, rootLogger *slog.Logger, sentryMiddleware func(http.HandlerFunc) http.HandlerFunc, bearerAuthMiddleware func(http.HandlerFunc) http.HandlerFunc, blocklistConfig BlocklistConfig, ) (http.HandlerFunc, func())
func MakeGetAccountByUsernameHandler ¶
func MakeGetAccountByUsernameHandler( getAccountByUsername app.GetAccountByUsername, registerUserVisit app.RegisterUserVisit, allowedOrigins *DomainSuffixes, rootLogger *slog.Logger, sentryMiddleware func(http.HandlerFunc) http.HandlerFunc, bearerAuthMiddleware func(http.HandlerFunc) http.HandlerFunc, blocklistConfig BlocklistConfig, ) (http.HandlerFunc, func())
func MakeGetHistoryHandler ¶
func MakeGetHistoryHandler( getHistory app.GetHistory, registerUserVisit app.RegisterUserVisit, allowedOrigins *DomainSuffixes, rootLogger *slog.Logger, sentryMiddleware func(http.HandlerFunc) http.HandlerFunc, bearerAuthMiddleware func(http.HandlerFunc) http.HandlerFunc, blocklistConfig BlocklistConfig, ) (http.HandlerFunc, func())
func MakeGetPlayerDataHandler ¶
func MakeGetPlayerDataHandler( getAndPersistPlayerWithCache app.GetAndPersistPlayerWithCache, registerUserVisit app.RegisterUserVisit, rootLogger *slog.Logger, sentryMiddleware func(http.HandlerFunc) http.HandlerFunc, bearerAuthMiddleware func(http.HandlerFunc) http.HandlerFunc, blocklistConfig BlocklistConfig, deprecated bool, ) (http.HandlerFunc, func())
func MakeGetPrestigesHandler ¶
func MakeGetPrestigesHandler( findMilestoneAchievements app.FindMilestoneAchievements, registerUserVisit app.RegisterUserVisit, allowedOrigins *DomainSuffixes, rootLogger *slog.Logger, sentryMiddleware func(http.HandlerFunc) http.HandlerFunc, blocklistConfig BlocklistConfig, ) (http.HandlerFunc, func())
func MakeGetSessionAtHandler ¶
func MakeGetSessionAtHandler( getSessionAt app.GetSessionAt, registerUserVisit app.RegisterUserVisit, allowedOrigins *DomainSuffixes, rootLogger *slog.Logger, sentryMiddleware func(http.HandlerFunc) http.HandlerFunc, bearerAuthMiddleware func(http.HandlerFunc) http.HandlerFunc, blocklistConfig BlocklistConfig, ) (http.HandlerFunc, func())
func MakeGetSessionsHandler ¶
func MakeGetSessionsHandler( getPlayerPITs app.GetPlayerPITs, computeSessions app.ComputeSessions, registerUserVisit app.RegisterUserVisit, allowedOrigins *DomainSuffixes, rootLogger *slog.Logger, sentryMiddleware func(http.HandlerFunc) http.HandlerFunc, bearerAuthMiddleware func(http.HandlerFunc) http.HandlerFunc, blocklistConfig BlocklistConfig, ) (http.HandlerFunc, func())
func MakeGetTagsHandler ¶
func MakeGetTagsHandler( getTags app.GetTags, registerUserVisit app.RegisterUserVisit, rootLogger *slog.Logger, sentryMiddleware func(http.HandlerFunc) http.HandlerFunc, bearerAuthMiddleware func(http.HandlerFunc) http.HandlerFunc, blocklistConfig BlocklistConfig, ) (http.HandlerFunc, func())
func MakeGetWrappedHandler ¶
func MakeGetWrappedHandler( getPlayerPITs app.GetPlayerPITs, computeSessions app.ComputeSessions, registerUserVisit app.RegisterUserVisit, allowedOrigins *DomainSuffixes, rootLogger *slog.Logger, sentryMiddleware func(http.HandlerFunc) http.HandlerFunc, bearerAuthMiddleware func(http.HandlerFunc) http.HandlerFunc, blocklistConfig BlocklistConfig, ) (http.HandlerFunc, func())
func MakePrismNoticesHandler ¶
func MakePrismNoticesHandler( getPrismNotices app.GetPrismNotices, registerUserVisit app.RegisterUserVisit, rootLogger *slog.Logger, sentryMiddleware func(http.HandlerFunc) http.HandlerFunc, bearerAuthMiddleware func(http.HandlerFunc) http.HandlerFunc, blocklistConfig BlocklistConfig, ) (http.HandlerFunc, func())
func NewBearerAuthMiddleware ¶
func NewBearerAuthMiddleware(validate app.ValidateSession) func(http.HandlerFunc) http.HandlerFunc
NewBearerAuthMiddleware returns a middleware that validates an Authorization: Bearer <session-id> header against the auth session store when present. It is passive: requests without an Authorization header pass through unchanged (preserving the legacy X-User-Id flow). When a header IS present but the session is unknown or expired, the request is rejected with 401 — otherwise a bearer would be silently ignored, which would let clients downgrade to the un-authenticated path just by sending a bad token.
func NewRateLimitMiddleware ¶
func NewRateLimitMiddleware(rateLimiter ratelimiting.RequestRateLimiter, onLimitExceeded http.HandlerFunc) func(http.HandlerFunc) http.HandlerFunc
func NewReportingMetaMiddleware ¶
func NewReportingMetaMiddleware(port string) func(http.HandlerFunc) http.HandlerFunc
func NewRequestLoggerMiddleware ¶
func NewRequestLoggerMiddleware(logger *slog.Logger) func(next http.HandlerFunc) http.HandlerFunc
func UserIDKeyFunc ¶
Types ¶
type AuthContext ¶
type AuthContext struct {
SessionID string
IdentityType domain.AuthSessionIdentityType
IdentityKey string
}
AuthContext is what the bearer middleware stashes into the request context when a valid Authorization header is present. Absent when the request had no Authorization header (legacy X-User-Id callers).
func AuthFromContext ¶
func AuthFromContext(ctx context.Context) (AuthContext, bool)
AuthFromContext returns the auth context attached by the bearer middleware, or (zero, false) when no bearer was sent.
type BlocklistConfig ¶
type Client ¶
Client is the normalized identity of the calling client, derived from the X-Client-Type and X-Client-Version request headers. Raw values are retained (truncated) for logging; Type and Version are the bounded, allowlisted values safe to use as metric labels.
func (Client) MetricAttributes ¶
MetricAttributes returns the bounded client labels for metric instruments. Kept here so the call sites stay consistent.
type DomainSuffixes ¶
type DomainSuffixes struct {
// contains filtered or unexported fields
}
func NewDomainSuffixes ¶
func NewDomainSuffixes(suffixes ...string) (*DomainSuffixes, error)
func (*DomainSuffixes) AnyMatch ¶
func (suffixes *DomainSuffixes) AnyMatch(origin string) bool
type HypixelAPIErrorResponse ¶
type UserID ¶
type UserID string
UserID represents a user identifier extracted from an HTTP request.
func (UserID) LowCardinalityString ¶
LowCardinalityString returns a low cardinality representation of the user ID. Returns "<missing>" for empty user IDs. For IDs shorter than 20 characters, it returns "<short-user-id>". Otherwise, it returns the full user ID (which is truncated to a maximum of 50 characters).
Source Files
¶
- auth_anonymous_login.go
- auth_middleware.go
- auth_refresh.go
- auth_types.go
- client.go
- cors.go
- get_account_by_username.go
- get_account_by_uuid.go
- history.go
- ip.go
- metrics.go
- middleware.go
- player_data.go
- prestiges.go
- prism_converters.go
- prism_notices.go
- rainbow_converters.go
- session_at.go
- sessions.go
- tags.go
- types.go
- userid.go
- wrapped.go