http

package
v0.0.0-...-53e3d08 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

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
}

Client client of http server

func NewClient

func NewClient(c ClientInfo) (*Client, error)

NewClient creates a new http client

func (*Client) Get

func (c *Client) Get(path string, params ...interface{}) ([]byte, error)

Get sends get request

func (*Client) Post

func (c *Client) Post(body []byte, path string, params ...interface{}) ([]byte, error)

Post sends post request

func (*Client) Put

func (c *Client) Put(body []byte, path string, params ...interface{}) ([]byte, error)

Put sends put request

func (*Client) SendPath

func (c *Client) SendPath(method, path string, body []byte, header map[string]string) ([]byte, error)

SendPath sends http request by path

func (*Client) SendUrl

func (c *Client) SendUrl(method, url string, body io.Reader, header map[string]string) (io.ReadCloser, error)

SendUrl sends http request by url

type ClientInfo

type ClientInfo struct {
	Address           string        `yaml:"address" json:"address"`
	Timeout           time.Duration `yaml:"timeout" json:"timeout" default:"5m"`
	KeepAlive         time.Duration `yaml:"keepalive" json:"keepalive" default:"10m"`
	Username          string        `yaml:"username" json:"username"`
	Password          string        `yaml:"password" json:"password"`
	utils.Certificate `yaml:",inline" json:",inline"`
}

ClientInfo http client config

type Headers

type Headers = http.Header

Headers http headers

type Params

type Params = map[string]string

Params http params

type Server

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

Server http server

func NewServer

func NewServer(c ServerInfo, a func(u, p string) bool) (*Server, error)

NewServer creates a new http server

func (*Server) Close

func (s *Server) Close() error

Close closese server

func (*Server) Handle

func (s *Server) Handle(handle func(Params, []byte) ([]byte, error), method, path string, params ...string)

Handle handle requests

func (*Server) Start

func (s *Server) Start() error

Start starts server

type ServerInfo

type ServerInfo struct {
	Address           string        `yaml:"address" json:"address"`
	Timeout           time.Duration `yaml:"timeout" json:"timeout" default:"5m"`
	utils.Certificate `yaml:",inline" json:",inline"`
}

ServerInfo http server config

Jump to

Keyboard shortcuts

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