plugins

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2025 License: MIT Imports: 4 Imported by: 0

README

plugins

import "github.com/cognusion/go-jar/plugins"

Overview

Package plugins provides support for Yaegi-style http.Handler "plugins", for use in JAR. Code should be self-contained. The standard library is available for imports, anything else needs GoPaths and whatnot defined, and isnt't greatly supported.

If the handler needs some configuration data, there is a map[string]string that may be used. If so, ensure you have a function called SetConfig(map[string]string) defined that will take the provided map and set it in your code. See testHandlerConfigSrc in the included _test file.

Index

Package files

plugins.go

type HandlerPlugin

type HandlerPlugin struct {
    Source   string
    FuncName string
    Config   map[string]string
    Options  InterpreterOptions
    // contains filtered or unexported fields
}

HandlerPlugin is a stuct to handle the creation, validation, and inclusion of yaegi-loaded "plugins"

func NewHandlerPlugin
func NewHandlerPlugin(src, funcName string) (*HandlerPlugin, error)

NewHandlerPlugin is a quick creator that also runs Bootrap, returning an error if Bootstrap did, otherwise returning a reference to the created HandlerPlugin.

func NewHandlerPluginWithConfig
func NewHandlerPluginWithConfig(src, funcName string, config map[string]string) (*HandlerPlugin, error)

NewHandlerPluginWithConfig is a quick creator that also runs Bootrap, returning an error if Bootstrap did, otherwise returning a reference to the created HandlerPlugin.

func (*HandlerPlugin) Bootstrap
func (h *HandlerPlugin) Bootstrap() (berr error)

Bootstrap is an initializer that must be called before Handler, and anytime the public attributes (Source, FuncName, Options) are changed.

func (*HandlerPlugin) CopyHandler
func (h *HandlerPlugin) CopyHandler() func(http.Handler) http.Handler

CopyHandler returns the Handler function itself.

func (*HandlerPlugin) Handler
func (h *HandlerPlugin) Handler(next http.Handler) http.Handler

Handler is a HandlerFunc representation of the HandlerPlugin

type InterpreterOptions

type InterpreterOptions = interp.Options

InterpreterOptions is used to change how the interpreter runs. Aliased so including packages needn't import interp directly.


Generated by godoc2md

Documentation

Overview

Package plugins provides support for Yaegi-style http.Handler "plugins", for use in JAR. Code should be self-contained. The standard library is available for imports, anything else needs GoPaths and whatnot defined, and isnt't greatly supported.

If the handler needs some configuration data, there is a `map[string]string` that may be used. If so, ensure you have a function called `SetConfig(map[string]string)` defined that will take the provided map and set it in your code. See `testHandlerConfigSrc` in the included _test file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HandlerPlugin

type HandlerPlugin struct {
	Source   string
	FuncName string
	Config   map[string]string
	Options  InterpreterOptions
	// contains filtered or unexported fields
}

HandlerPlugin is a stuct to handle the creation, validation, and inclusion of yaegi-loaded "plugins"

func NewHandlerPlugin

func NewHandlerPlugin(src, funcName string) (*HandlerPlugin, error)

NewHandlerPlugin is a quick creator that also runs Bootrap, returning an error if Bootstrap did, otherwise returning a reference to the created HandlerPlugin.

func NewHandlerPluginWithConfig

func NewHandlerPluginWithConfig(src, funcName string, config map[string]string) (*HandlerPlugin, error)

NewHandlerPluginWithConfig is a quick creator that also runs Bootrap, returning an error if Bootstrap did, otherwise returning a reference to the created HandlerPlugin.

func (*HandlerPlugin) Bootstrap

func (h *HandlerPlugin) Bootstrap() (berr error)

Bootstrap is an initializer that *must* be called before Handler, and anytime the public attributes (Source, FuncName, Options) are changed.

func (*HandlerPlugin) CopyHandler

func (h *HandlerPlugin) CopyHandler() func(http.Handler) http.Handler

CopyHandler returns the Handler function itself.

func (*HandlerPlugin) Handler

func (h *HandlerPlugin) Handler(next http.Handler) http.Handler

Handler is a HandlerFunc representation of the HandlerPlugin

type InterpreterOptions

type InterpreterOptions = interp.Options

InterpreterOptions is used to change how the interpreter runs. Aliased so including packages needn't import interp directly.

Jump to

Keyboard shortcuts

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