plugin

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2018 License: MIT Imports: 6 Imported by: 0

README

plugins

functional modules in this folder e.g.

  • ACL
  • IP Limit
  • Proxy to servers
  • Cache

Question:

how to use plugin in api-gateway

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Recover

func Recover(plgName string)

Recover func to get panic detail

Types

type Context

type Context struct {
	Ctx    context.Context // ctx control signal for multi goroutine
	Method string          // request method
	Path   string          // request Path
	// contains filtered or unexported fields
}

Context ... contains infomation to transfer

func New

func New(w http.ResponseWriter, req *http.Request,
	numPlugin int, plugins []Plugin,
) *Context

New generate a Context TODO: do this work with pool

func (*Context) Abort

func (c *Context) Abort()

Abort process to stop calling next plugin [done] TODO: ignore response here, should call JSON, or String manually

func (*Context) AbortWithStatus

func (c *Context) AbortWithStatus(status int)

AbortWithStatus abort process and set response status

func (*Context) Aborted

func (c *Context) Aborted() bool

Aborted ...

func (*Context) Error

func (c *Context) Error() error

Error get the global error of context

func (*Context) JSON

func (c *Context) JSON(status int, v interface{})

JSON ...

func (*Context) Next

func (c *Context) Next()

Next ...

func (*Context) Request

func (c *Context) Request() *http.Request

Request ...

func (*Context) Reset

func (c *Context) Reset()

Reset ... donot call this manually

func (*Context) ResponseWriter

func (c *Context) ResponseWriter() http.ResponseWriter

ResponseWriter ...

func (*Context) Set

func (c *Context) Set(req *http.Request, w http.ResponseWriter)

Set set request and responseWriter

func (*Context) SetError

func (c *Context) SetError(err error)

SetError ...

func (*Context) SetResponseWriter

func (c *Context) SetResponseWriter(w http.ResponseWriter)

SetResponseWriter ...

func (*Context) String

func (c *Context) String(status int, s string)

String ...

type PlgStatus added in v1.1.0

type PlgStatus string

PlgStatus ...

const (
	// Reloading ...
	Reloading PlgStatus = "reloading"
	// Stopped ...
	Stopped PlgStatus = "stopped"
	// Working ...
	Working PlgStatus = "working"
)

type Plugin

type Plugin interface {
	Handle(ctx *Context)
	Status() PlgStatus
	Enabled() bool
	Name() string
	Enable(enabled bool)
}

Plugin type Plugin want to save all plugin

Directories

Path Synopsis
Package cache ...
Package cache ...
Package httplog to log http request
Package httplog to log http request
Package proxy ...
Package proxy ...

Jump to

Keyboard shortcuts

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