plug

package
v0.0.0-...-e37af68 Latest Latest
Warning

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

Go to latest
Published: May 6, 2018 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package plug encapsulates the plugin style that this framework uses. Using either the code method, which relies on the go plugin package, as well as the package package (yes.) Or the configuration style of defining models within a json file. Plugins are added to a pluginManager which is added to the server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HealthCheck

func HealthCheck(w http.ResponseWriter, req *http.Request, ctx config.AppContext)

HealthCheck is the generic health check endpoint for the user, instantianted when called for in the config file.

func MakeHandler

func MakeHandler(ctx config.AppContext, fn HandlerFunc) http.HandlerFunc

MakeHandler will wrap a Application Context up into a handler so that users have access to things like their database connection etc in each handler.

Types

type Crud

type Crud interface {
	Get(w http.ResponseWriter, req *http.Request, ctx config.AppContext)
	Put(w http.ResponseWriter, req *http.Request, ctx config.AppContext)
	Delete(w http.ResponseWriter, req *http.Request, ctx config.AppContext)
	Post(w http.ResponseWriter, req *http.Request, ctx config.AppContext)
}

Crud interface for the functions required by our API objects

type HandlerFunc

type HandlerFunc func(http.ResponseWriter, *http.Request, config.AppContext)

HandlerFunc type for the unwrapped version of a handler function.

type Manager

type Manager struct {
	Plugs []*Plug
}

Manager object to hold our plugins

func CreatePlugManager

func CreatePlugManager(conf *config.ManagerConfig) (*Manager, error)

CreatePlugManager creates the manager object for Plugins

func (*Manager) AttachRoutes

func (manager *Manager) AttachRoutes(router *mux.Router, ctx config.AppContext) error

AttachRoutes to your router!!

func (*Manager) InitGenericRoutes

func (*Manager) InitGenericRoutes(router *mux.Router, conf *config.ManagerConfig, ctx config.AppContext) error

type Message

type Message struct {
	Status  int         `json:"status"`
	Message string      `json:"message"`
	Results interface{} `json:"results"`
}

Message is the standard response sent to user with the generic routes set by the model methods

type Plug

type Plug struct {
	Name        string
	Description string
	Path        string
	Crud        *Crud
	Model       []*config.Field
}

Plug object to hold each plugin

Jump to

Keyboard shortcuts

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