plugin

package
v1.8.5 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrHookNotFound          = errors.New("hook not found")
	ErrHookExecutionFailed   = errors.New("hook execution failed")
	ErrHookAlreadyRegistered = errors.New("hook already registered")
)
View Source
var (
	ErrPluginNotFound      = errors.New("plugin not found")
	ErrPluginInvalidFormat = errors.New("invalid WASM format")
	ErrPluginLoadFailed    = errors.New("plugin load failed")
)

Functions

This section is empty.

Types

type FailureMode

type FailureMode int
const (
	FailFast FailureMode = iota
	LogAndContinue
	Fallback

	DefaultFailureMode FailureMode = FailFast
)

func ParseFailureMode

func ParseFailureMode(s string) FailureMode

func (FailureMode) String

func (f FailureMode) String() string

type HookData added in v1.8.4

type HookData struct {
	ContentID    int            `json:"contentId"`
	UserID       int            `json:"userId"`
	Title        string         `json:"title"`
	Content      string         `json:"content"`
	Tags         []string       `json:"tags"`
	Status       string         `json:"status"`
	PostType     string         `json:"postType"`
	CustomFields map[string]any `json:"customFields,omitempty"`
}

HookData is the JSON structure sent to and received from plugin hooks.

type HookHandler

type HookHandler func(ctx context.Context, data []byte) ([]byte, error)

type HookName

type HookName string
const (
	HookBeforeSave     HookName = "BeforeSaveContent"
	HookAfterPublish   HookName = "AfterPublishContent"
	HookBeforeDelete   HookName = "BeforeDeleteContent"
	HookAfterCreate    HookName = "AfterCreateContent"
	HookAfterUnpublish HookName = "AfterUnpublishContent"
	HookOnPluginLoaded HookName = "OnPluginLoaded"

	DefaultPriority = 100
)

func ResolveWasmHookName

func ResolveWasmHookName(exportSuffix string) HookName

func (HookName) String

func (h HookName) String() string

type HookRegistration

type HookRegistration struct {
	PluginName      string
	HookName        HookName
	Priority        int
	Handler         HookHandler
	FailureMode     FailureMode
	FallbackHandler HookHandler
}

type HookResult added in v1.8.4

type HookResult struct {
	Title        *string        `json:"title"`
	CustomFields map[string]any `json:"customFields,omitempty"`
}

HookResult is the parse view of a before_save hook's returned JSON. Title is a pointer so an absent key (no change) is distinguishable from an explicit empty string (invalid, rejected by ValidateTitle).

type Plugin

type Plugin struct {
	Name     string
	FilePath string
	Status   Status
	LoadedAt time.Time
}

type Status

type Status string
const (
	StatusLoaded   Status = "loaded"
	StatusFailed   Status = "failed"
	StatusUnloaded Status = "unloaded"
)

func (Status) String

func (s Status) String() string

Jump to

Keyboard shortcuts

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