package
1.5.0
Repository: https://github.com/cognusion/go-jar.git
Documentation: pkg.go.dev

# 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

# Functions

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

# Structs

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

# Type aliases

InterpreterOptions is used to change how the interpreter runs.