Documentation ¶
Index ¶
Constants ¶
View Source
const ( // StatusContinue ... StatusContinue = 100 // StatusSwitchingProtocols ... StatusSwitchingProtocols = 101 // StatusOK ... StatusOK = 200 // StatusCreated ... StatusCreated = 201 // StatusAccepted ... StatusAccepted = 202 // StatusNonAuthoritativeInfo ... StatusNonAuthoritativeInfo = 203 // StatusNoContent ... StatusNoContent = 204 // StatusResetContent ... StatusResetContent = 205 // StatusPartialContent ... StatusPartialContent = 206 // StatusMultipleChoices ... StatusMultipleChoices = 300 // StatusMovedPermanently ... StatusMovedPermanently = 301 // StatusFound ... StatusFound = 302 // StatusSeeOther ... StatusSeeOther = 303 // StatusNotModified ... StatusNotModified = 304 // StatusUseProxy ... StatusUseProxy = 305 // StatusTemporaryRedirect ... StatusTemporaryRedirect = 307 // StatusBadRequest ... StatusBadRequest = 400 StatusUnauthorized = 401 // StatusPaymentRequired ... StatusPaymentRequired = 402 // StatusForbidden ... StatusForbidden = 403 // StatusNotFound ... StatusNotFound = 404 // StatusMethodNotAllowed ... StatusMethodNotAllowed = 405 // StatusNotAcceptable ... StatusNotAcceptable = 406 // StatusProxyAuthRequired ... StatusProxyAuthRequired = 407 // StatusRequestTimeout ... StatusRequestTimeout = 408 // StatusConflict ... StatusConflict = 409 // StatusGone ... StatusGone = 410 // StatusLengthRequired ... StatusLengthRequired = 411 // StatusPreconditionFailed ... StatusPreconditionFailed = 412 // StatusRequestEntityTooLarge ... StatusRequestEntityTooLarge = 413 // StatusRequestURITooLong ... StatusRequestURITooLong = 414 // StatusUnsupportedMediaType ... StatusUnsupportedMediaType = 415 // StatusRequestedRangeNotSatisfiable ... StatusRequestedRangeNotSatisfiable = 416 // StatusExpectationFailed ... StatusExpectationFailed = 417 // StatusTeapot ... StatusTeapot = 418 // StatusPreconditionRequired ... StatusPreconditionRequired = 428 // StatusTooManyRequests ... StatusTooManyRequests = 429 // StatusRequestHeaderFieldsTooLarge ... StatusRequestHeaderFieldsTooLarge = 431 StatusUnavailableForLegalReasons = 451 // StatusInternalServerError ... StatusInternalServerError = 500 // StatusNotImplemented ... StatusNotImplemented = 501 // StatusBadGateway ... StatusBadGateway = 502 StatusServiceUnavailable = 503 // StatusGatewayTimeout ... StatusGatewayTimeout = 504 // StatusHTTPVersionNotSupported ... StatusHTTPVersionNotSupported = 505 // StatusNetworkAuthenticationRequired ... StatusNetworkAuthenticationRequired = 511 // StatusErrorCodeReturned 针对微服务定制的错误返回status StatusErrorCodeReturned = 800 )
View Source
const ( // HeaderAcceptEncoding ... HeaderAcceptEncoding = "Accept-Encoding" // HeaderContentType ... HeaderContentType = "Content-Type" // HRPC Errord HeaderHRPCErr = "HRPC-Errord" )
Headers
View Source
const ( // MIMEApplicationJSON ... MIMEApplicationJSON = "application/json" // MIMEApplicationJSONCharsetUTF8 ... MIMEApplicationJSONCharsetUTF8 = MIMEApplicationJSON + "; " + charsetUTF8 // MIMEApplicationProtobuf ... MIMEApplicationProtobuf = "application/protobuf" )
MIME types
View Source
const ModName = "server.gin"
ModName ..
Variables ¶
View Source
var ( // ErrGRPCResponseValid ... ErrGRPCResponseValid = grpc.Errorf(codes.Internal, "response valid") // ErrGRPCInvokeLen ... ErrGRPCInvokeLen = grpc.Errorf(codes.Internal, "invoke request without len 2 res") )
View Source
var ErrNotFound = HTTPError{ Code: StatusNotFound, Message: "not found", }
ErrNotFound defines StatusNotFound error.
Functions ¶
func StatusText ¶
StatusText returns a text for the HTTP status code. It returns the empty string if the code is unknown.
Types ¶
type Config ¶
type Config struct { Host string Port int Deployment string Mode string DisableMetric bool DisableTrace bool // ServiceAddress service address in registry info, default to 'Host:Port' ServiceAddress string SlowQueryThresholdInMilli int64 // contains filtered or unexported fields }
Config HTTP config
func (*Config) WithLogger ¶
WithLogger ...
type GRPCProxyMessage ¶
type GRPCProxyMessage struct { Error int `protobuf:"varint,1,opt,name=error" json:"error"` Message string `protobuf:"bytes,2,opt,name=msg" json:"msg"` Data proto.Message `protobuf:"bytes,3,opt,name=data" json:"data"` }
GRPCProxyMessage ...
func (*GRPCProxyMessage) MarshalJSONPB ¶
func (m *GRPCProxyMessage) MarshalJSONPB(jsb *jsonpb.Marshaler) ([]byte, error)
MarshalJSONPB ...
type HTTPError ¶
HTTPError wraps handler error.
func NewHTTPError ¶
NewHTTPError constructs a new HTTPError instance.
type Server ¶
Server ...
func (*Server) GracefulStop ¶
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
type WebSocket ¶
type WebSocket struct { Pattern string Handler WebSocketFunc *websocket.Upgrader Header http.Header }
WebSocket ..
func WebSocketOptions ¶
func WebSocketOptions(pattern string, handler WebSocketFunc, opts ...WebSocketOption) *WebSocket
WebSocketOptions ..
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
Click to show internal directories.
Click to hide internal directories.