Documentation
¶
Index ¶
- type LineDocxForExportContext
- type LineHtmlForExportContext
- type LineMarkdownForExportContext
- type LineOdtForExportContext
- type LinePDFForExportContext
- type LineTxtForExportContext
- type LocaleLoadContext
- type PreAuthorizeContext
- type PreAuthorizeDecision
- type PreAuthzFailureContext
- func (c *PreAuthzFailureContext) Body() string
- func (c *PreAuthzFailureContext) Handled() bool
- func (c *PreAuthzFailureContext) Headers() map[string]string
- func (c *PreAuthzFailureContext) Respond(status int, body string)
- func (c *PreAuthzFailureContext) SetHeader(key, value string)
- func (c *PreAuthzFailureContext) Status() int
- type UserJoinLeaveContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LineDocxForExportContext ¶
type LineDocxForExportContext struct {
Line *models.LineModel
LineContent *string
Apool *apool.APool
AttribLine *string
Text *string
PadId *string
Alignment *string // "left", "center", "right", "justify"
Heading *string // e.g., "Heading1", "Normal", etc. -> word styles
}
LineDocxForExportContext is the context for the getLineDocxForExport hook
type LineMarkdownForExportContext ¶ added in v0.0.5
type LineOdtForExportContext ¶
type LineOdtForExportContext struct {
Line *models.LineModel
LineContent *string
Apool *apool.APool
AttribLine *string
Text *string
PadId *string
Alignment *string // "left", "center", "right", "justify"
IsHeading *bool
OutlineLevel *int
Heading *string // e.g., "Heading 1", "Text Body", etc. -> odt styles
}
LineOdtForExportContext is the context for the getLineOdtForExport hook
type LinePDFForExportContext ¶
type LinePDFForExportContext struct {
Line *models.LineModel
LineContent *string
Apool *apool.APool
AttribLine *string
Text *string
PadId *string
Alignment *string // "left", "center", "right", "justify"
FontSize *float64
Bold *bool
Heading *string // e.g., "h1", "h2", etc.
}
LinePDFForExportContext is the context for the getLinePDFForExport hook
type LineTxtForExportContext ¶
type LineTxtForExportContext struct {
Line *models.LineModel
LineContent *string
Apool *apool.APool
AttribLine *string
Text *string
PadId *string
}
LineTxtForExportContext is the context for the getLineTxtForExport hook
type LocaleLoadContext ¶
type PreAuthorizeContext ¶ added in v0.6.3
type PreAuthorizeContext struct {
// Path is the request path, e.g. "/p/mypad" (input, read-only).
Path string
// RequireAdmin is true when the request is for an /admin-auth page (input,
// read-only).
RequireAdmin bool
// contains filtered or unexported fields
}
PreAuthorizeContext is passed to preAuthorize hook callbacks. It is the Go counterpart of the original hook context {req, res, next}: callbacks inspect Path/RequireAdmin and answer by calling Permit or Deny; calling neither defers to the regular authenticate/authorize steps. The classic use case is permitting static resource paths so they skip authentication.
Semantics adapted from the original's hooks.aCallFirst: the Go hook system runs every registered callback (in unspecified order) instead of stopping at the first one that answers, so a single Deny always wins over any number of Permits. As in the original, Permits on /admin-auth pages (RequireAdmin) are filtered out so plugins cannot accidentally grant admin privileges to the general public.
func (*PreAuthorizeContext) Decision ¶ added in v0.6.3
func (c *PreAuthorizeContext) Decision() PreAuthorizeDecision
Decision aggregates the callbacks' answers, mirroring the original's result handling: admin pages drop all permits, an empty result list defers, any remaining false denies, and all-true permits.
func (*PreAuthorizeContext) Deny ¶ added in v0.6.3
func (c *PreAuthorizeContext) Deny()
Deny explicitly denies access.
func (*PreAuthorizeContext) Permit ¶ added in v0.6.3
func (c *PreAuthorizeContext) Permit()
Permit explicitly grants access. On admin pages the permit is ignored (see the type documentation).
type PreAuthorizeDecision ¶ added in v0.6.3
type PreAuthorizeDecision int
PreAuthorizeDecision is the aggregated answer of all preAuthorize hook callbacks for a request.
const ( // PreAuthorizeDefer means no callback answered: fall through to the regular // authenticate/authorize steps (the original's empty result list). PreAuthorizeDefer PreAuthorizeDecision = iota // PreAuthorizePermit means access was explicitly granted: skip the remaining // steps (the original's `return next()` when every result is truthy). PreAuthorizePermit // PreAuthorizeDeny means access was explicitly denied: respond with 403 // unless a preAuthzFailure callback overrides the response. PreAuthorizeDeny )
type PreAuthzFailureContext ¶ added in v0.6.3
type PreAuthzFailureContext struct {
// Path is the request path (input, read-only).
Path string
// RequireAdmin is true when the request is for an /admin-auth page (input,
// read-only).
RequireAdmin bool
// contains filtered or unexported fields
}
PreAuthzFailureContext is passed to preAuthzFailure hook callbacks when a preAuthorize callback denied access. A callback can take over the error response — the original's "return truthy after writing to res" — by calling Respond (optionally adding headers via SetHeader, e.g. a Location header for a login redirect). If no callback responds, the default 403 Forbidden is sent.
func (*PreAuthzFailureContext) Body ¶ added in v0.6.3
func (c *PreAuthzFailureContext) Body() string
Body returns the recorded response body.
func (*PreAuthzFailureContext) Handled ¶ added in v0.6.3
func (c *PreAuthzFailureContext) Handled() bool
Handled reports whether a callback overrode the default error response.
func (*PreAuthzFailureContext) Headers ¶ added in v0.6.3
func (c *PreAuthzFailureContext) Headers() map[string]string
Headers returns the recorded response headers (may be nil).
func (*PreAuthzFailureContext) Respond ¶ added in v0.6.3
func (c *PreAuthzFailureContext) Respond(status int, body string)
Respond marks the failure as handled and records the response to send instead of the default 403 Forbidden.
func (*PreAuthzFailureContext) SetHeader ¶ added in v0.6.3
func (c *PreAuthzFailureContext) SetHeader(key, value string)
SetHeader records a response header to set alongside the Respond status and body.
func (*PreAuthzFailureContext) Status ¶ added in v0.6.3
func (c *PreAuthzFailureContext) Status() int
Status returns the recorded response status.
type UserJoinLeaveContext ¶ added in v0.5.0
type UserJoinLeaveContext struct {
PadId string
AuthorId string
// BroadcastChat sends a chat message to all clients in the pad room without persisting it.
// The message map is serialized as the "message" field inside a CHAT_MESSAGE COLLABROOM event.
BroadcastChat func(message map[string]any)
}
UserJoinLeaveContext is passed to userJoin and userLeave hooks.