Documentation
¶
Index ¶
- func JWTAuthMiddleware(cfg JWTAuthConfig, next http.Handler) http.Handler
- func RetryAfterMiddleware(check func(r *http.Request) (reject bool, status int, retryAfter int), ...) http.Handler
- func UserIDFromContext(ctx context.Context) string
- func UserIDMiddleware(header string, next http.Handler) http.Handler
- func VersionCheckMiddleware(header, minVersion string, next http.Handler) http.Handler
- func WithUserID(ctx context.Context, userID string) context.Context
- type Handler
- func (h *Handler) Routes() http.Handler
- func (h *Handler) ServePull(w http.ResponseWriter, r *http.Request)
- func (h *Handler) ServePush(w http.ResponseWriter, r *http.Request)
- func (h *Handler) ServeRegister(w http.ResponseWriter, r *http.Request)
- func (h *Handler) ServeSchema(w http.ResponseWriter, r *http.Request)
- func (h *Handler) ServeSnapshot(w http.ResponseWriter, r *http.Request)
- func (h *Handler) ServeTableMeta(w http.ResponseWriter, r *http.Request)
- type JWTAuthConfig
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func JWTAuthMiddleware ¶
func JWTAuthMiddleware(cfg JWTAuthConfig, next http.Handler) http.Handler
JWTAuthMiddleware validates a Bearer token from the Authorization header, extracts the user ID from the configured claim, and sets it in context.
func RetryAfterMiddleware ¶
func RetryAfterMiddleware(check func(r *http.Request) (reject bool, status int, retryAfter int), next http.Handler) http.Handler
RetryAfterMiddleware rejects requests when the check function returns true. The consuming app provides the policy (rate limiting, maintenance mode, etc.).
func UserIDFromContext ¶
UserIDFromContext extracts the user ID from the request context. The consuming application is responsible for setting this via WithUserID.
func UserIDMiddleware ¶
UserIDMiddleware is an http.Handler middleware that extracts the user ID from a header and sets it in the request context. The consuming application should replace this with their own auth middleware.
func VersionCheckMiddleware ¶
VersionCheckMiddleware validates the client version header against the minimum.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler provides net/http handlers for sync endpoints.
func (*Handler) ServePull ¶
func (h *Handler) ServePull(w http.ResponseWriter, r *http.Request)
ServePull handles POST /sync/pull.
func (*Handler) ServePush ¶
func (h *Handler) ServePush(w http.ResponseWriter, r *http.Request)
ServePush handles POST /sync/push.
func (*Handler) ServeRegister ¶
func (h *Handler) ServeRegister(w http.ResponseWriter, r *http.Request)
ServeRegister handles POST /sync/register.
func (*Handler) ServeSchema ¶
func (h *Handler) ServeSchema(w http.ResponseWriter, r *http.Request)
ServeSchema handles GET /sync/schema.
func (*Handler) ServeSnapshot ¶
func (h *Handler) ServeSnapshot(w http.ResponseWriter, r *http.Request)
ServeSnapshot handles POST /sync/snapshot.
func (*Handler) ServeTableMeta ¶
func (h *Handler) ServeTableMeta(w http.ResponseWriter, r *http.Request)
ServeTableMeta handles GET /sync/tables.
type JWTAuthConfig ¶
type JWTAuthConfig struct {
// Secret is the HS256 shared secret. Mutually exclusive with JWKSURL.
Secret []byte
// JWKSURL is the RS256/ES256 JWKS endpoint URL. Mutually exclusive with Secret.
JWKSURL string
// UserClaim is the JWT claim containing the user ID (default: "sub").
UserClaim string
}
JWTAuthConfig configures JWT-based authentication middleware.