http

package
v1.1.14 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Host string
	Port int
	Mode string
	Name string
}

Config HTTP config

func (*Config) Address

func (config *Config) Address() string

Address ...

func (*Config) Build

func (config *Config) Build() *Server

Build create server instance, then initialize it with necessary interceptor

func (*Config) WithHost

func (config *Config) WithHost(host string) *Config

WithHost ...

func (*Config) WithMode

func (config *Config) WithMode(mode string) *Config

WithMode ...

func (*Config) WithName

func (config *Config) WithName(name string) *Config

WithName ...

func (*Config) WithPort

func (config *Config) WithPort(port int) *Config

WithPort ...

type Server

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

Server ...

func (*Server) GracefulStop

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

GracefulStop implements server.Server interface it will stop gin server gracefully

func (*Server) Info

func (s *Server) Info() *server.ServiceInfo

Info returns server info, used by governor and consumer balancer

func (*Server) Serve

func (s *Server) Serve() error

Serve implements server.Server interface.

func (*Server) ServerInterceptor

func (s *Server) ServerInterceptor(fn gin.HandlerFunc) *Server

ServerInterceptor ...

func (*Server) Stop

func (s *Server) Stop() error

Stop implements server.Server interface it will terminate gin server immediately

func (*Server) Upgrade

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

Upgrade protocol to WebSocket

type WebSocket

type WebSocket struct {
	Pattern string
	Name    string
	Handler WebSocketFunc
	*websocket.Upgrader
	Header http.Header
}

WebSocket ..

func WebSocketOptions

func WebSocketOptions(pattern, name string, handler WebSocketFunc, opts ...WebSocketOption) *WebSocket

WebSocketOptions ..

func (*WebSocket) Upgrade

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

Upgrade get upgrage request

type WebSocketConn

type WebSocketConn interface {
	Subprotocol() string
	Close() error
	LocalAddr() net.Addr
	RemoteAddr() net.Addr
	WriteControl(messageType int, data []byte, deadline time.Time) error
	NextWriter(messageType int) (io.WriteCloser, error)
	WritePreparedMessage(pm *websocket.PreparedMessage) error
	WriteMessage(messageType int, data []byte) error
	SetWriteDeadline(t time.Time) error
	NextReader() (messageType int, r io.Reader, err error)
	ReadMessage() (messageType int, p []byte, err error)
	SetReadDeadline(t time.Time) error
	SetReadLimit(limit int64)
	CloseHandler() func(code int, text string) error
	SetCloseHandler(h func(code int, text string) error)
	PingHandler() func(appData string) error
	SetPingHandler(h func(appData string) error)
	PongHandler() func(appData string) error
	SetPongHandler(h func(appData string) error)
	UnderlyingConn() net.Conn
	EnableWriteCompression(enable bool)
	SetCompressionLevel(level int) error
}

WebSocketConn websocket conn, see websocket.Conn

type WebSocketFunc

type WebSocketFunc func(WebSocketConn, error)

WebSocketFunc ..

type WebSocketOption

type WebSocketOption func(*WebSocket)

WebSocketOption ..

Jump to

Keyboard shortcuts

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