Documentation
¶
Overview ¶
Package middleware holds cross-cutting Gin middlewares that don't fit a single feature package. Today it's just the incognito flag — handlers that would normally write search history or library entries consult IsIncognito(c) at the top and skip the write silently, while still returning the same HTTP response so the frontend UX stays fluid.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Incognito ¶
func Incognito() gin.HandlerFunc
Incognito reads X-JackUI-Incognito from the request and tags the context when it's "1" / "true" (case-insensitive). Mount on the /api group.
EventSource can't set headers, so SSE callers (/api/search/stream) instead pass ?incognito=1 in the query — accepted here as a fallback for the same reason the auth middleware accepts ?token=.
func IsIncognito ¶
IsIncognito returns true when the current request was marked incognito by the middleware. Safe to call from any handler — defaults to false when the middleware isn't installed (e.g. unit tests bypassing the router).
func IsRevealHidden ¶
IsRevealHidden reports whether the current request opted into seeing hidden items. Defaults to false when the middleware isn't installed (unit tests).
func RedactToken ¶
RedactToken masks every token=... credential in s with token=REDACTED.
func RedactingLogFormatter ¶
func RedactingLogFormatter(p gin.LogFormatterParams) string
RedactingLogFormatter is gin's default access-log line (timestamp, status, latency, client IP, method, path+query) minus terminal colors, with credential query values masked via RedactToken. Wire it with gin.LoggerWithFormatter instead of gin.Logger(): the default logger printed media URLs verbatim, leaking the ?token= JWT of every stream/subtitle request into the server log (verified in production).
func RevealHidden ¶
func RevealHidden() gin.HandlerFunc
RevealHidden reads X-JackUI-Reveal-Hidden from the request and tags the context when it's truthy. Mount on the /api group, alongside Incognito.
EventSource can't set headers, so SSE/media callers pass ?revealHidden=1 in the query instead — accepted here for the same reason auth accepts ?token=.
Types ¶
This section is empty.