rest

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

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

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 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) 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) 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) 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) 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
	// contains filtered or unexported fields
}

Rest 接收端端点

func (*Rest) AddRouter

func (rest *Rest) AddRouter(method string, routers ...*endpoint.Router) *Rest

AddRouter 注册1个或者多个路由

For GET, POST, PUT, PATCH and DELETE requests the respective shortcut functions can be used.

func (*Rest) AddRouterWithParams added in v0.14.0

func (rest *Rest) AddRouterWithParams(router *endpoint.Router, params ...interface{}) 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) 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) RemoveRouterWithParams added in v0.14.0

func (rest *Rest) RemoveRouterWithParams(from string, params ...interface{}) error

func (*Rest) Router

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

func (*Rest) Start

func (rest *Rest) Start() error

func (*Rest) Stop

func (rest *Rest) Stop()

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