httpapi

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 3, 2026 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(config Config) http.Handler

Types

type API

type API struct {
	// contains filtered or unexported fields
}

type APIKey

type APIKey struct {
	ID        string
	Name      string
	Key       string
	CreatedAt time.Time
	ExpiresAt time.Time
}

type APIKeyInfo

type APIKeyInfo struct {
	ID         string
	Name       string
	CreatedAt  time.Time
	LastUsedAt time.Time
	ExpiresAt  time.Time
}

type AuditEvent

type AuditEvent struct {
	Time            time.Time
	RequestID       string
	ClientIP        string
	Action          string
	Collection      string
	DocumentID      string
	ActorID         string
	ActorCollection schema.CollectionSlug
}

type AuthIdentity

type AuthIdentity struct {
	Collection   schema.CollectionSlug
	Actor        store.Document
	PreviewEpoch uint64
}

type AuthSession

type AuthSession struct {
	ID         string
	Token      string
	Collection schema.CollectionSlug
	User       store.Document
	ExpiresAt  time.Time
}

type AuthSessionInfo

type AuthSessionInfo struct {
	ID         string
	CreatedAt  time.Time
	LastSeenAt time.Time
	ExpiresAt  time.Time
	IPAddress  string
	UserAgent  string
	Current    bool
}

type Config

type Config struct {
	Manifest                     schema.Manifest
	ManifestForRequest           func(context.Context, *AuthIdentity) (schema.Snapshot, error)
	Engine                       *operation.Engine
	AdminAssets                  fs.FS
	MaxBodyBytes                 int64
	SecureCookies                bool
	Login                        func(context.Context, string, string, string, LoginMetadata) (AuthSession, error)
	Session                      func(context.Context, string) (AuthSession, error)
	RotateSession                func(context.Context, string) (AuthSession, error)
	Logout                       func(context.Context, string) error
	LogoutAll                    func(context.Context, string) error
	Sessions                     func(context.Context, string) ([]AuthSessionInfo, error)
	RevokeSession                func(context.Context, string, string) error
	RequestPasswordReset         func(context.Context, string, string) error
	ResetPassword                func(context.Context, string, string, string) error
	RequestVerification          func(context.Context, string, string) error
	VerifyEmail                  func(context.Context, string, string) error
	ChangePassword               func(context.Context, string, string, string) error
	AuthBootstrapAvailable       func(context.Context, string) (bool, error)
	CreateAuthUser               func(context.Context, string, store.Values, string, *AuthIdentity) (store.Document, error)
	CreateAuthUserLocalized      func(context.Context, string, store.Values, string, *AuthIdentity, LocaleOptions) (store.Document, error)
	CreateAPIKey                 func(context.Context, string, string, time.Time) (APIKey, error)
	APIKeys                      func(context.Context, string) ([]APIKeyInfo, error)
	RevokeAPIKey                 func(context.Context, string, string) error
	AuthenticateAPIKey           func(context.Context, string) (AuthIdentity, error)
	AuthenticateExternal         func(context.Context, map[string][]string) (AuthIdentity, error)
	PreviewLifecycleEpoch        func() uint64
	CreateCollectionPreviewToken func(context.Context, string, string, *AuthIdentity) (PreviewToken, error)
	CreateGlobalPreviewToken     func(context.Context, string, *AuthIdentity) (PreviewToken, error)
	RevokePreviewToken           func(context.Context, string, *AuthIdentity) error
	FindCollectionPreview        func(context.Context, string, string, string) (store.Document, error)
	FindGlobalPreview            func(context.Context, string, string) (store.Document, error)
	GetPreference                func(context.Context, *AuthIdentity, string) (json.RawMessage, error)
	SetPreference                func(context.Context, *AuthIdentity, string, json.RawMessage) (json.RawMessage, error)
	DeletePreference             func(context.Context, *AuthIdentity, string) error
	ResetPreferences             func(context.Context, *AuthIdentity) error
	ForceUnlock                  func(context.Context, string, string, *AuthIdentity) error
	DocumentLock                 func(context.Context, string, string, *AuthIdentity) (protocol.DocumentLockEnvelope, error)
	AcquireDocumentLock          func(context.Context, string, string, bool, *AuthIdentity) (protocol.DocumentLockEnvelope, error)
	ReleaseDocumentLock          func(context.Context, string, string, *AuthIdentity) error
	SchedulePublish              func(context.Context, string, string, time.Time, int, *AuthIdentity) (store.ScheduledPublish, error)
	ScheduledPublishes           func(context.Context, string, string, *AuthIdentity) ([]store.ScheduledPublish, error)
	CancelScheduledPublish       func(context.Context, string, string, string, *AuthIdentity) error
	AllowAuthIPAttempt           func(context.Context, string, string, int, time.Duration) (bool, error)
	AllowAuthAttempt             func(context.Context, string, string, string, int, time.Duration) (bool, error)
	AllowedOrigins               []string
	AllowedRequestHeaders        []string
	AllowedHosts                 []string
	TrustedProxies               []netip.Prefix
	AuthRateLimit                int
	AuthRateWindow               time.Duration
	Audit                        func(AuditEvent)
	Ready                        func(context.Context) error
	Observe                      func(RequestObservation)
	RequestError                 func(RequestErrorEvent)
	RequestTimeout               time.Duration
	ContentSecurityPolicy        string
	DisableContentSecurityPolicy bool
	StrictTransportSecurity      string
	AcquireUpload                func(context.Context, string) (release func(), err error)
	Upload                       func(context.Context, string, string, io.Reader, store.Values, *AuthIdentity, bool) (store.Document, error)
	RemoteUpload                 func(context.Context, string, string, store.Values, *AuthIdentity) (store.Document, error)
	UploadLocalized              func(context.Context, string, string, io.Reader, store.Values, *AuthIdentity, LocaleOptions, bool) (store.Document, error)
	RemoteUploadLocalized        func(context.Context, string, string, store.Values, *AuthIdentity, LocaleOptions) (store.Document, error)
	UpdateUploadImage            func(context.Context, string, string, float64, float64, float64, float64, float64, float64, int, *AuthIdentity) (store.Document, error)
	Duplicate                    func(context.Context, string, string, store.Values, *AuthIdentity, LocaleOptions) (store.Document, error)
	OpenUpload                   func(context.Context, string, string, *AuthIdentity) (io.ReadCloser, storage.Object, error)
	PluginEndpoints              []PluginEndpoint
	PluginTransports             []PluginEndpoint
	CustomEndpoints              []CustomEndpoint
}

type CustomEndpoint

type CustomEndpoint struct {
	Method       string
	Pattern      string
	Scope        CustomEndpointScope
	Resource     schema.CollectionSlug
	MaxBodyBytes int64
	Handler      func(http.ResponseWriter, *http.Request, string, string, map[string]string, *store.Document, schema.CollectionSlug, func(context.Context, string, string) error, func(error, string))
}

type CustomEndpointScope

type CustomEndpointScope uint8
const (
	CustomEndpointRoot CustomEndpointScope = iota
	CustomEndpointCollection
	CustomEndpointGlobal
)

type LocaleOptions

type LocaleOptions struct {
	Locale          string
	FallbackLocales []schema.LocaleCode
	DisableFallback bool
	AllLocales      bool
}

LocaleOptions carries the validated transport-level localization selection into storage-aware application operations such as upload duplication.

type LoginMetadata

type LoginMetadata struct {
	IPAddress string
	UserAgent string
}

type PluginEndpoint

type PluginEndpoint struct {
	Method       string
	Path         string
	MaxBodyBytes int64
	Handler      func(http.ResponseWriter, *http.Request, string, *store.Document, schema.CollectionSlug, func(context.Context, string, string) error, func(error, string))
}

type PreviewToken

type PreviewToken struct {
	Token      string
	Resource   string
	Slug       string
	DocumentID string
	ExpiresAt  time.Time
}

type RequestErrorEvent

type RequestErrorEvent struct {
	Time      time.Time
	RequestID string
	Method    string
	Path      string
	Error     error
	Panic     bool
	Stack     string
}

type RequestObservation

type RequestObservation struct {
	Time          time.Time
	RequestID     string
	Method        string
	Path          string
	Status        int
	ErrorCode     string
	ResponseBytes int64
	Duration      time.Duration
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL