Back to godoc.org

Package http

v0.1.0
Latest Go to latest

The latest major version is .

Published: Oct 9, 2020 | License: Apache-2.0 | Module: github.com/UnderTreeTech/waterdrop

Index

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

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

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier