rest

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentTypeKey  = "Content-Type"
	JsonContextType = "application/json"
)
View Source
const Type = "http"

Type 组件类型

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Server      string
	CertFile    string
	CertKeyFile string
}

Config Rest 服务配置

type Endpoint added in v0.17.0

type Endpoint = Rest

Endpoint 别名

type RequestMessage

type RequestMessage struct {

	//路径参数
	Params httprouter.Params
	// contains filtered or unexported fields
}

RequestMessage http请求消息

func (*RequestMessage) Body

func (r *RequestMessage) Body() []byte

func (RequestMessage) From

func (r RequestMessage) From() string

func (*RequestMessage) GetError added in v0.15.0

func (r *RequestMessage) GetError() error

func (*RequestMessage) GetMsg

func (r *RequestMessage) GetMsg() *types.RuleMsg

func (*RequestMessage) GetParam

func (r *RequestMessage) GetParam(key string) string

func (*RequestMessage) Headers

func (r *RequestMessage) Headers() textproto.MIMEHeader

func (*RequestMessage) Request

func (r *RequestMessage) Request() *http.Request

func (*RequestMessage) SetBody

func (r *RequestMessage) SetBody(body []byte)

func (*RequestMessage) SetError added in v0.15.0

func (r *RequestMessage) SetError(err error)

func (*RequestMessage) SetMsg

func (r *RequestMessage) SetMsg(msg *types.RuleMsg)

func (*RequestMessage) SetStatusCode

func (r *RequestMessage) SetStatusCode(statusCode int)

type ResponseMessage

type ResponseMessage struct {
	// contains filtered or unexported fields
}

ResponseMessage http响应消息

func (*ResponseMessage) Body

func (r *ResponseMessage) Body() []byte

func (*ResponseMessage) From

func (r *ResponseMessage) From() string

func (*ResponseMessage) GetError added in v0.15.0

func (r *ResponseMessage) GetError() error

func (*ResponseMessage) GetMsg

func (r *ResponseMessage) GetMsg() *types.RuleMsg

func (*ResponseMessage) GetParam

func (r *ResponseMessage) GetParam(key string) string

func (*ResponseMessage) Headers

func (r *ResponseMessage) Headers() textproto.MIMEHeader

func (*ResponseMessage) Response

func (r *ResponseMessage) Response() http.ResponseWriter

func (*ResponseMessage) SetBody

func (r *ResponseMessage) SetBody(body []byte)

func (*ResponseMessage) SetError added in v0.15.0

func (r *ResponseMessage) SetError(err error)

func (*ResponseMessage) SetMsg

func (r *ResponseMessage) SetMsg(msg *types.RuleMsg)

func (*ResponseMessage) SetStatusCode

func (r *ResponseMessage) SetStatusCode(statusCode int)

type Rest

type Rest struct {
	endpoint.BaseEndpoint
	//配置
	Config     Config
	RuleConfig types.Config
	Server     *http.Server

	//事件回调函数
	OnEventFunc endpoint.OnEvent
	// contains filtered or unexported fields
}

Rest 接收端端点

func (*Rest) AddRouter

func (rest *Rest) AddRouter(router *endpoint.Router, params ...interface{}) (string, error)

func (*Rest) Close added in v0.14.0

func (rest *Rest) Close() error

func (*Rest) DELETE

func (rest *Rest) DELETE(routers ...*endpoint.Router) *Rest

func (*Rest) Destroy added in v0.14.0

func (rest *Rest) Destroy()

Destroy 销毁

func (*Rest) GET

func (rest *Rest) GET(routers ...*endpoint.Router) *Rest

func (*Rest) GlobalOPTIONS added in v0.16.0

func (rest *Rest) GlobalOPTIONS(handler http.Handler) *Rest

func (*Rest) HEAD

func (rest *Rest) HEAD(routers ...*endpoint.Router) *Rest

func (*Rest) Id added in v0.14.0

func (rest *Rest) Id() string

func (*Rest) Init added in v0.14.0

func (rest *Rest) Init(ruleConfig types.Config, configuration types.Configuration) error

Init 初始化

func (*Rest) New added in v0.14.0

func (rest *Rest) New() types.Node

func (*Rest) OPTIONS

func (rest *Rest) OPTIONS(routers ...*endpoint.Router) *Rest

func (*Rest) PATCH

func (rest *Rest) PATCH(routers ...*endpoint.Router) *Rest

func (*Rest) POST

func (rest *Rest) POST(routers ...*endpoint.Router) *Rest

func (*Rest) PUT

func (rest *Rest) PUT(routers ...*endpoint.Router) *Rest

func (*Rest) Printf added in v0.14.0

func (rest *Rest) Printf(format string, v ...interface{})

func (*Rest) RemoveRouter added in v0.17.0

func (rest *Rest) RemoveRouter(routerId string, params ...interface{}) error

func (*Rest) Router

func (rest *Rest) Router() *httprouter.Router

func (*Rest) Start

func (rest *Rest) Start() error

func (*Rest) Type added in v0.14.0

func (rest *Rest) Type() string

Type 组件类型

Jump to

Keyboard shortcuts

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