plugins

package
v0.0.0-...-154c46d Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListPluginsStr

func ListPluginsStr() string

ListPluginsStr returns a string listing the registered plugins.

func LoadESPlugin

func LoadESPlugin(router *mux.Router, p ESPlugin, mw []middleware.Middleware) error

func LoadPlugin

func LoadPlugin(router *mux.Router, p Plugin) error

LoadPlugin is currently responsible for two things: firstly, it executes the plugin's initFunc to ensure it makes all the initializations before the plugin is functional and second, calling loadRoutes

func LoadRSPlugin

func LoadRSPlugin(router *mux.Router, p RSPlugin, mw []middleware.Middleware) error

func RegisterPlugin

func RegisterPlugin(p Plugin)

RegisterPlugin plugs in plugin. All plugins must have a name: preferably lowercase and one word. The name of the plugin must be unique. A plugin, however, may not define any routes, but still be useful, like a middleware.

Types

type ESPlugin

type ESPlugin interface {

	// mw takes a array of middleware to be intialized by ES Plugin
	InitFunc(mw []middleware.Middleware) error
	// contains filtered or unexported methods
}

ElasticSearchPlugin holds the plugin for ES

type Plugin

type Plugin interface {

	// InitFunc returns the plugin's setup function that is executed
	// before the plugin routes are loaded in the router.
	InitFunc() error

	// The plugin's elastic search middleware, if any.
	ESMiddleware() []middleware.Middleware

	// The plugin's reactive search middleware, if any.
	RSMiddleware() []middleware.Middleware
	// contains filtered or unexported methods
}

Plugin is a type that holds information about the plugin.

func ListPlugins

func ListPlugins() []Plugin

ListPlugins returns the list of plugins that are currently registered.

type PluginBy

type PluginBy func(p1, p2 Plugin) bool

By is the type of a "less" function that defines the ordering of Plugins.

func (PluginBy) PluginSort

func (by PluginBy) PluginSort(plugins []Plugin)

Sort is a method on the function type, By, that sorts the argument slice according to the function.

type RSPlugin

type RSPlugin interface {

	// mw takes a array of middleware to be intialized by ES Plugin
	InitFunc(mw []middleware.Middleware) error
	// contains filtered or unexported methods
}

ReactiveSearchPlugin holds the plugin for ReactiveSearch API

type Route

type Route struct {
	// Name is the name of the route. In order to avoid conflicts in
	// the router, the name preferably should be a combination of both
	// http method type and the path. For example: "Get foobar" would
	// be an appropriate name for [GET foobar] endpoint.
	Name string

	// Methods represents an array of HTTP method type. It is preferable
	// to use values defined in net/http package to avoid typos.
	Methods []string

	// Path is the path that it expects to serve the requests on.
	// If the path contains any variables, then they must be declared
	// in accordance to the format define by the router to which
	// these routes are registered which in our case is: gorilla/mux.
	Path string

	// PathPrefix serves as a matcher for the URL path prefix.
	// This matches if the given template is a prefix of the full
	// URL path. See Route.Path() for details on the tpl argument.
	// Note that it does not treat slashes specially ("/foobar/"
	// will be matched by the prefix "/foo") so you may want to
	// use a trailing slash here.
	PathPrefix string

	// HandlerFunc is the handler function that is responsible for
	// responding the request made to this route.
	HandlerFunc http.HandlerFunc

	// Description about this route.
	Description string
}

Route is a type that contains information about a route.

type RouteBy

type RouteBy func(r1, r2 Route) bool

By is the type of a "less" function that defines the ordering of routes.

func (RouteBy) RouteSort

func (by RouteBy) RouteSort(routes []Route)

Sort is a method on the function type, By, that sorts the argument slice according to the function.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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