http

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2020 License: Apache-2.0 Imports: 34 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(config *ClientConfig) *Client

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, req *Request, reply interface{}) error

func (*Client) Get

func (c *Client) Get(ctx context.Context, req *Request, reply interface{}) error

func (*Client) NewRequest

func (c *Client) NewRequest(ctx context.Context, method string, req *Request, reply interface{}) (*resty.Request, error)

func (*Client) Post

func (c *Client) Post(ctx context.Context, req *Request, reply interface{}) error

func (*Client) Put

func (c *Client) Put(ctx context.Context, req *Request, reply interface{}) error

type ClientConfig

type ClientConfig struct {
	HostURL             string
	Timeout             time.Duration
	SlowRequestDuration time.Duration

	EnableSign  bool
	EnableDebug bool

	Key    string
	Secret string
}

type Request

type Request struct {
	URI         string
	QueryParams url.Values
	Body        interface{}
	PathParams  map[string]string
}

type Server

type Server struct {
	*gin.Engine
	Server *http.Server
	// contains filtered or unexported fields
}

func NewServer

func NewServer(config *ServerConfig) *Server

func (*Server) Header

func (s *Server) Header() gin.HandlerFunc

Header middleware is commonly used for p2p communication, like ios/android application, or server to server call

func (*Server) Metric

func (s *Server) Metric() gin.HandlerFunc

func (*Server) Start

func (s *Server) Start() net.Addr

start server

func (*Server) Stop

func (s *Server) Stop(ctx context.Context) error

shutdown server graceful

func (*Server) Upgrade added in v0.2.0

func (s *Server) Upgrade(ws *WebSocket) gin.IRoutes

upgrade http to websocket

type ServerConfig

type ServerConfig struct {
	Addr string

	Timeout time.Duration
	Mode    string

	SlowRequestDuration time.Duration
	WatchConfig         bool

	EnableMetric bool
}

type SignVerify

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

func NewSignatureVerify

func NewSignatureVerify(config *ClientConfig, r *redis.Redis) *SignVerify

func (*SignVerify) SetRequestTimeout

func (s *SignVerify) SetRequestTimeout(timeout int)

func (*SignVerify) SetSecretURL

func (s *SignVerify) SetSecretURL(url string)

func (*SignVerify) SetSkipsURL

func (s *SignVerify) SetSkipsURL(url string)

func (*SignVerify) Signature

func (s *SignVerify) Signature() gin.HandlerFunc

Signature middleware is commonly used for p2p communication, like ios/android application, or server to server call

type WebSocket added in v0.2.0

type WebSocket struct {
	Path    string
	Handler WebSocketHandler

	*websocket.Upgrader
	*websocket.Conn
}

func NewWebSocket added in v0.2.0

func NewWebSocket(path string, handler WebSocketHandler) *WebSocket

func (*WebSocket) Upgrade added in v0.2.0

func (ws *WebSocket) Upgrade(w http.ResponseWriter, r *http.Request)

type WebSocketHandler added in v0.2.0

type WebSocketHandler func(*WebSocket)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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