Documentation ¶
Index ¶
- Constants
- func HandleResponse(r *gohttp.Response) ([]byte, error)
- func Respond(c *routing.Context, httpCode int, obj []byte)
- func RespondMsg(c *routing.Context, httpCode int, code, msg string)
- func RespondStream(c *routing.Context, httpCode int, bodyStream io.Reader, bodySize int)
- type Client
- func (c *Client) Call(service, function string, payload []byte) ([]byte, error)
- func (c *Client) GetJSON(url string) ([]byte, error)
- func (c *Client) GetURL(url string, header ...map[string]string) (*gohttp.Response, error)
- func (c *Client) PostJSON(url string, payload []byte) ([]byte, error)
- func (c *Client) PostURL(url string, body io.Reader, header ...map[string]string) (*gohttp.Response, error)
- func (c *Client) SendUrl(method, url string, body io.Reader, header ...map[string]string) (*gohttp.Response, error)
- type ClientConfig
- type ClientOptions
- type Response
- type Server
- type ServerConfig
Constants ¶
View Source
const ContentTypeJSON = "application/json"
ContentTypeJSON the json content type of request
Variables ¶
This section is empty.
Functions ¶
func HandleResponse ¶
HandleResponse handles response
func RespondMsg ¶
RespondMsg RespondMsg
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client client of http server
type ClientConfig ¶
type ClientConfig struct { Address string `yaml:"address" json:"address"` Timeout time.Duration `yaml:"timeout" json:"timeout" default:"30s"` KeepAlive time.Duration `yaml:"keepalive" json:"keepalive" default:"30s"` MaxIdleConns int `yaml:"maxIdleConns" json:"maxIdleConns" default:"100"` IdleConnTimeout time.Duration `yaml:"idleConnTimeout" json:"idleConnTimeout" default:"90s"` TLSHandshakeTimeout time.Duration `yaml:"tlsHandshakeTimeout" json:"tlsHandshakeTimeout" default:"10s"` ExpectContinueTimeout time.Duration `yaml:"expectContinueTimeout" json:"expectContinueTimeout" default:"1s"` utils.Certificate `yaml:",inline" json:",inline"` }
ClientConfig client config
func (ClientConfig) ToClientOptions ¶
func (cc ClientConfig) ToClientOptions() (*ClientOptions, error)
ToClientOptions converts client config to client options
type ClientOptions ¶
type ClientOptions struct { Address string TLSConfig *tls.Config Timeout time.Duration KeepAlive time.Duration MaxIdleConns int IdleConnTimeout time.Duration TLSHandshakeTimeout time.Duration ExpectContinueTimeout time.Duration }
ClientOptions client options
func NewClientOptions ¶
func NewClientOptions() *ClientOptions
NewClientOptions creates client options with default values
type Server ¶
func NewServer ¶
func NewServer(cfg ServerConfig, handler fasthttp.RequestHandler) *Server
NewServer new server
type ServerConfig ¶
type ServerConfig struct { Address string `yaml:"address" json:"address" default:":80"` Concurrency int `yaml:"concurrency" json:"concurrency"` DisableKeepalive bool `yaml:"disableKeepalive" json:"disableKeepalive"` TCPKeepalive bool `yaml:"tcpKeepalive" json:"tcpKeepalive"` MaxRequestBodySize int `yaml:"maxRequestBodySize" json:"maxRequestBodySize"` ReadTimeout time.Duration `yaml:"readTimeout" json:"readTimeout"` WriteTimeout time.Duration `yaml:"writeTimeout" json:"writeTimeout"` IdleTimeout time.Duration `yaml:"idleTimeout" json:"idleTimeout"` utils.Certificate `yaml:",inline" json:",inline"` }
ServerConfig server config
Click to show internal directories.
Click to hide internal directories.