app

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TL_CONTEXT                  = "TL_context"
	TL_DEFER_MAP                = "TL_defer_map"
	TL_CURRENT_MODULE_FULL_PATH = "TL_current_module_full_path"
)

Variables

This section is empty.

Functions

func ClearCleanup added in v0.4.1

func ClearCleanup(thread *starlark.Thread, key string)

ClearCleanup clears a defer function from the thread local

func CreatePluginApi added in v0.3.0

func CreatePluginApi(f StarlarkFunction, opType PluginFunctionType) utils.PluginFunc

func CreatePluginApiName added in v0.4.0

func CreatePluginApiName(
	f func(thread *starlark.Thread, fn *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error),
	opType PluginFunctionType,
	name string) utils.PluginFunc

CreatePluginApiName creates a Clace plugin function

func DeferCleanup added in v0.4.1

func DeferCleanup(thread *starlark.Thread, key string, deferFunc DeferFunc, strict bool)

DeferCleanup defers a close function to call when the API handler is done

func FetchPluginState added in v0.4.1

func FetchPluginState(thread *starlark.Thread, key string) any

FetchPluginState fetches a value from the thread local for the plugin

func GetContext added in v0.4.1

func GetContext(thread *starlark.Thread) context.Context

func RegisterPlugin

func RegisterPlugin(name string, builder utils.NewPluginFunc, funcs []utils.PluginFunc)

RegisterPlugin registers a plugin with Clace

func SavePluginState added in v0.4.1

func SavePluginState(thread *starlark.Thread, key string, value any)

SavePluginState saves a value in the thread local for the plugin

Types

type App

type App struct {
	*utils.Logger
	*utils.AppEntry
	Name         string
	CustomLayout bool

	Config *util.AppConfig
	// contains filtered or unexported fields
}

App is the main object that represents a Clace app. It is created when the app is loaded

func NewApp

func NewApp(sourceFS *util.SourceFs, workFS *util.WorkFs, logger *utils.Logger,
	appEntry *utils.AppEntry, systemConfig *utils.SystemConfig,
	plugins map[string]utils.PluginSettings) *App

func (*App) Audit

func (a *App) Audit() (*utils.ApproveResult, error)

func (*App) Close

func (a *App) Close() error

func (*App) Initialize

func (a *App) Initialize() error

func (*App) Reload

func (a *App) Reload(force, immediate bool) (bool, error)

func (*App) ResetFS added in v0.3.0

func (a *App) ResetFS()

func (*App) ServeHTTP

func (a *App) ServeHTTP(w http.ResponseWriter, r *http.Request)

type AppPlugins added in v0.4.0

type AppPlugins struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewAppPlugins added in v0.4.0

func NewAppPlugins(app *App, pluginConfig map[string]utils.PluginSettings, appAccounts []utils.AccountLink) *AppPlugins

func (*AppPlugins) GetPlugin added in v0.4.0

func (p *AppPlugins) GetPlugin(pluginInfo *utils.PluginInfo, accountName string) (any, error)

type DeferEntry added in v0.4.1

type DeferEntry struct {
	Func   DeferFunc
	Strict bool
}

type DeferFunc added in v0.4.1

type DeferFunc func() error

type PluginFunctionType added in v0.4.0

type PluginFunctionType int
const (
	READ PluginFunctionType = iota
	WRITE
	READ_WRITE
)

type Request

type Request struct {
	AppName     string
	AppPath     string
	AppUrl      string
	PagePath    string
	PageUrl     string
	Method      string
	IsDev       bool
	IsPartial   bool
	PushEvents  bool
	HtmxVersion string
	Headers     http.Header
	RemoteIP    string
	UrlParams   map[string]string
	Form        url.Values
	Query       url.Values
	PostForm    url.Values
	Data        any
}

Request is a starlark.Value that represents an HTTP request. A Request is created from the Go http.Request and passed to the starlark handler function as it only argument. The Data field is updated with the handler's response and then the template evaluation is done with the same Request

func (Request) Attr

func (r Request) Attr(name string) (starlark.Value, error)

func (Request) AttrNames

func (r Request) AttrNames() []string

func (Request) Freeze

func (r Request) Freeze()

func (Request) Hash

func (r Request) Hash() (uint32, error)

func (Request) String

func (r Request) String() string

func (Request) Truth

func (r Request) Truth() starlark.Bool

func (Request) Type

func (r Request) Type() string

type SSEMessage

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

type StarlarkFunction added in v0.4.0

type StarlarkFunction func(thread *starlark.Thread, fn *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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