context

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseContext

type BaseContext struct {
	Context
	Index   int8
	Filters FilterChain
	Timeout time.Duration
	Ctx     context.Context

	// the response context will return.
	TargetResp *client.Response
	// client call response.
	SourceResp interface{}
	// happen error
	Err error
}

BaseContext

func NewBaseContext

func NewBaseContext() *BaseContext

NewBaseContext create base context.

func (*BaseContext) Abort

func (c *BaseContext) Abort()

Abort filter chain break , filter after the current filter will not executed.

func (*BaseContext) AbortWithError

func (c *BaseContext) AbortWithError(message string, err error)

AbortWithError filter chain break , filter after the current filter will not executed. And log will print.

func (*BaseContext) AppendFilterFunc

func (c *BaseContext) AppendFilterFunc(ff ...FilterFunc)

AppendFilterFunc append filter func.

func (*BaseContext) Next

func (c *BaseContext) Next()

Next should be used only inside middleware. It executes the pending handlers in the chain inside the calling handler. See example in GitHub.

type Context

type Context interface {
	Next()
	Abort()
	AbortWithError(string, error)
	AppendFilterFunc(ff ...FilterFunc)

	Status(code int)
	StatusCode() int
	WriteWithStatus(int, []byte) (int, error)
	Write([]byte) (int, error)
	AddHeader(k, v string)
	GetHeader(k string) string
	GetUrl() string
	GetMethod() string

	BuildFilters()

	API(router.API)
	GetAPI() *router.API
	Api(api *model.Api)
	GetApi() *model.Api

	GetClientIP() string
	GetApplicationName() string

	WriteErr(p interface{})
}

Context run context

type FilterChain

type FilterChain []FilterFunc

FilterChain filter chain

type FilterFunc

type FilterFunc func(Context)

FilterFunc filter func, filter

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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