http

package
v0.0.0-...-1a2806f Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// POST method
	POST = "POST"
	// GET method
	GET = "GET"

	//DELETE method
	DELETE = "DELETE"

	//RequestTypeText text format
	RequestTypeText = 0x01
	//RequestTypeJSON json format
	RequestTypeJSON = 0x02
	//RequestTypePB protobuf3 byte buffer format
	RequestTypePB = 0x03
	//RequestTypeByte byte buffer format
	RequestTypeByte = 0x04
	//ContentTypeText request type text
	ContentTypeText = "application/x-www-form-urlencoded"
	//ContentTypeJSON request type json
	ContentTypeJSON = "application/json;charset=UTF-8"
	//ContentTypeByte request type buffer
	ContentTypeByte = "application/octet-stream" // "application/x-protobuf"  //
	//ResponseTypeText response type text
	ResponseTypeText = 0x01
	//ResponseTypeJSON response type json
	ResponseTypeJSON = 0x02
	//ResponseTypeXML response type xml
	ResponseTypeXML = 0x03
	//ResponseTypePB response protobuf3 type buffer
	ResponseTypePB = 0x04
	//ResponseTypeByte response type buffer
	ResponseTypeByte = 0x05

	//ConnTimeoutMS conn timeout
	ConnTimeoutMS = 5000
	//ServeTimeoutMS request timeout
	ServeTimeoutMS = 10000
)

eHTTPRequestType

Variables

This section is empty.

Functions

func NewServer

func NewServer(conf config.IConfig, agentFunc network.AgentCreateFunc, agentCloseFunc network.AgentCloseFunc) network.IServer

NewServer create http server

func Request

func Request(url string, method string, requestType int, header interface{}, data interface{}, responseType int, results interface{}, connTimeoutMs int, serveTimeoutMs int) error

Request do http request with data

func TextParamsValue

func TextParamsValue(param map[string]interface{}) []byte

TextParamsValue get params formats

Types

type ClientConfig

type ClientConfig struct {
	Nodes     []common.NodeInfo `mapstructure:"nodes"`
	Timeout   time.Duration     `mapstructure:"timeout"`
	QueueSize int               `mapstructure:"queue_size"`
}

ClientConfig http client config

func (*ClientConfig) GetQueueSize

func (c *ClientConfig) GetQueueSize() int

GetQueueSize get module queue size

type ConnSet

type ConnSet map[net.Conn]struct{}

ConnSet http conn set

type Server

type Server struct {
	Conf     *ServerConfig
	NewAgent network.AgentCreateFunc

	CloseAgent network.AgentCloseFunc
	// contains filtered or unexported fields
}

Server websocket server define

func (*Server) Close

func (s *Server) Close()

Close websocket server

func (*Server) ListenAndServe

func (s *Server) ListenAndServe()

ListenAndServe start serve

type ServerConfig

type ServerConfig struct {
	Address   string `mapstructure:"address"`
	QueueSize int    `mapstructure:"queue_size"`
}

ServerConfig http server config

func (*ServerConfig) GetQueueSize

func (s *ServerConfig) GetQueueSize() int

GetQueueSize get module queue size

Jump to

Keyboard shortcuts

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