Documentation ¶
Index ¶
- Constants
- Variables
- func AnnotateContext(ctx context.Context, req *http.Request, rpcMethodName string, ...) (context.Context, error)
- func FormatCloseMessage(closeCode int, text string) []byte
- func ForwardResponseMessage(ctx context.Context, w http.ResponseWriter, req *http.Request, ...)
- func ForwardResponseStream(ctx context.Context, w http.ResponseWriter, req *http.Request, ...)
- func GetDefaultCfg() fiber.Config
- func HTTPPathPattern(ctx context.Context) (string, bool)
- func HTTPStatusFromCode(code codes.Code) int
- func IsCloseError(err error, codes ...int) bool
- func IsUnexpectedCloseError(err error, expectedCodes ...int) bool
- func IsWebSocketUpgrade(c *fiber.Ctx) bool
- func JoinMessages(c *websocket.Conn, term string) io.Reader
- func NewServerMetadataContext(ctx context.Context, md ServerMetadata) context.Context
- func NewWs(handler func(*fiber.Ctx, *Conn), config ...Config) fiber.Handler
- func NewWsStream(ctx *fiber.Ctx, conn *Conn) grpc.ServerStream
- func RPCMethod(ctx context.Context) (string, bool)
- type AnnotateContextOption
- type Builder
- type Cfg
- type Config
- type Conn
- type Delimited
- type ServerMetadata
- type ServerTransportStream
- func (s *ServerTransportStream) Header() metadata.MD
- func (s *ServerTransportStream) Method() string
- func (s *ServerTransportStream) SendHeader(md metadata.MD) error
- func (s *ServerTransportStream) SetHeader(md metadata.MD) error
- func (s *ServerTransportStream) SetTrailer(md metadata.MD) error
- func (s *ServerTransportStream) Trailer() metadata.MD
Constants ¶
const ( CloseNormalClosure = 1000 CloseGoingAway = 1001 CloseProtocolError = 1002 CloseUnsupportedData = 1003 CloseNoStatusReceived = 1005 CloseAbnormalClosure = 1006 CloseInvalidFramePayloadData = 1007 ClosePolicyViolation = 1008 CloseMessageTooBig = 1009 CloseMandatoryExtension = 1010 CloseInternalServerErr = 1011 CloseServiceRestart = 1012 CloseTryAgainLater = 1013 CloseTLSHandshake = 1015 )
Close codes defined in RFC 6455, section 11.7.
const ( // TextMessage denotes a text data message. The text message payload is // interpreted as UTF-8 encoded text data. TextMessage = 1 // BinaryMessage denotes a binary data message. BinaryMessage = 2 // CloseMessage denotes a close control message. The optional message // payload contains a numeric code and text. Use the FormatCloseMessage // function to format a close message payload. CloseMessage = 8 // PingMessage denotes a ping control message. The optional message payload // is UTF-8 encoded text. PingMessage = 9 // PongMessage denotes a pong control message. The optional message payload // is UTF-8 encoded text. PongMessage = 10 )
The message types are defined in RFC 6455, section 11.8.
const MetadataHeaderPrefix = "Grpc-Metadata-"
MetadataHeaderPrefix is the http prefix that represents custom metadata parameters to or from a gRPC call.
const MetadataPrefix = "grpcgateway-"
MetadataPrefix is prepended to permanent HTTP header keys (as specified by the IANA) when added to the gRPC context.
const MetadataTrailerPrefix = "Grpc-Trailer-"
MetadataTrailerPrefix is prepended to gRPC metadata as it is converted to HTTP headers in a response handled by grpc-gateway
Variables ¶
Functions ¶
func AnnotateContext ¶ added in v0.1.2
func FormatCloseMessage ¶
FormatCloseMessage formats closeCode and text as a WebSocket close message. An empty message is returned for code CloseNoStatusReceived.
func ForwardResponseMessage ¶ added in v0.1.2
func ForwardResponseStream ¶ added in v0.1.2
func GetDefaultCfg ¶
func GetDefaultCfg() fiber.Config
func HTTPPathPattern ¶ added in v0.1.2
HTTPPathPattern returns the HTTP path pattern string relating to the HTTP handler, if one exists. The format of the returned string is defined by the google.api.http path template type.
func HTTPStatusFromCode ¶ added in v0.1.2
HTTPStatusFromCode converts a gRPC error code into the corresponding HTTP response status. See: https://github.com/googleapis/googleapis/blob/master/google/rpc/code.proto
func IsCloseError ¶
IsCloseError returns boolean indicating whether the error is a *CloseError with one of the specified codes.
func IsUnexpectedCloseError ¶
IsUnexpectedCloseError returns boolean indicating whether the error is a *CloseError with a code not in the list of expected codes.
func IsWebSocketUpgrade ¶
func IsWebSocketUpgrade(c *fiber.Ctx) bool
IsWebSocketUpgrade returns true if the client requested upgrade to the WebSocket protocol.
func JoinMessages ¶
JoinMessages concatenates received messages to create a single io.Reader. The string term is appended to each message. The returned reader does not support concurrent calls to the Read method.
func NewServerMetadataContext ¶ added in v0.1.2
func NewServerMetadataContext(ctx context.Context, md ServerMetadata) context.Context
NewServerMetadataContext creates a new context with ServerMetadata
func NewWs ¶
NewWs returns a new `handler func(*Conn)` that upgrades a client to the websocket protocol, you can pass an optional config.
func NewWsStream ¶
func NewWsStream(ctx *fiber.Ctx, conn *Conn) grpc.ServerStream
Types ¶
type AnnotateContextOption ¶ added in v0.1.2
type Cfg ¶
type Cfg struct { Prefork bool `json:"prefork"` ServerHeader string `json:"server_header"` StrictRouting bool `json:"strict_routing"` CaseSensitive bool `json:"case_sensitive"` Immutable bool `json:"immutable"` UnescapePath bool `json:"unescape_path"` ETag bool `json:"etag"` BodyLimit int `json:"body_limit"` Concurrency int `json:"concurrency"` Templates struct { Dir string `json:"dir"` Ext string `json:"ext"` } `json:"templates"` ReadTimeout time.Duration `json:"read_timeout"` WriteTimeout time.Duration `json:"write_timeout"` IdleTimeout time.Duration `json:"idle_timeout"` ReadBufferSize int `json:"read_buffer_size"` WriteBufferSize int `json:"write_buffer_size"` CompressedFileSuffix string `json:"compressed_file_suffix"` ProxyHeader string `json:"proxy_header"` GETOnly bool `json:"get_only"` DisableKeepalive bool `json:"disable_keepalive"` DisableDefaultDate bool `json:"disable_default_date"` DisableDefaultContentType bool `json:"disable_default_content_type"` DisableHeaderNormalizing bool `json:"disable_header_normalizing"` DisableStartupMessage bool `json:"disable_startup_message"` ReduceMemoryUsage bool `json:"reduce_memory_usage"` }
type Config ¶
type Config struct { // Filter defines a function to skip middleware. // Optional. Default: nil Filter func(*fiber.Ctx) bool // HandshakeTimeout specifies the duration for the handshake to complete. HandshakeTimeout time.Duration // Subprotocols specifies the client's requested subprotocols. Subprotocols []string // Allowed Origin's based on the Origin header, this validate the request origin to // prevent cross-site request forgery. Everything is allowed if left empty. Origins []string // ReadBufferSize and WriteBufferSize specify I/O buffer sizes in bytes. If a buffer // size is zero, then a useful default size is used. The I/O buffer sizes // do not limit the size of the messages that can be sent or received. ReadBufferSize, WriteBufferSize int // EnableCompression specifies if the client should attempt to negotiate // per message compression (RFC 7692). Setting this value to true does not // guarantee that compression will be supported. Currently only "no context // takeover" modes are supported. EnableCompression bool }
Config ...
type Conn ¶
Conn https://godoc.org/github.com/gorilla/websocket#pkg-index
func (*Conn) Cookies ¶
Cookies is used for getting a cookie value by key Defaults to empty string "" if the cookie doesn't exist. If a default value is given, it will return that value if the cookie doesn't exist.
func (*Conn) Locals ¶
Locals makes it possible to pass interface{} values under string keys scoped to the request and therefore available to all following routes that match the request.
type Delimited ¶ added in v0.1.2
type Delimited interface { // Delimiter returns the record separator for the stream. Delimiter() []byte }
Delimited defines the streaming delimiter.
type ServerMetadata ¶ added in v0.1.2
ServerMetadata consists of metadata sent from gRPC server.
func ServerMetadataFromContext ¶ added in v0.1.2
func ServerMetadataFromContext(ctx context.Context) (md ServerMetadata, ok bool)
ServerMetadataFromContext returns the ServerMetadata in ctx
type ServerTransportStream ¶ added in v0.1.2
type ServerTransportStream struct {
// contains filtered or unexported fields
}
ServerTransportStream implements grpc.ServerTransportStream. It should only be used by the generated files to support grpc.SendHeader outside of gRPC server use.
func (*ServerTransportStream) Header ¶ added in v0.1.2
func (s *ServerTransportStream) Header() metadata.MD
Header returns the header metadata of the stream.
func (*ServerTransportStream) Method ¶ added in v0.1.2
func (s *ServerTransportStream) Method() string
Method returns the method for the stream.
func (*ServerTransportStream) SendHeader ¶ added in v0.1.2
func (s *ServerTransportStream) SendHeader(md metadata.MD) error
SendHeader sets the header metadata.
func (*ServerTransportStream) SetHeader ¶ added in v0.1.2
func (s *ServerTransportStream) SetHeader(md metadata.MD) error
SetHeader sets the header metadata.
func (*ServerTransportStream) SetTrailer ¶ added in v0.1.2
func (s *ServerTransportStream) SetTrailer(md metadata.MD) error
SetTrailer sets the trailer metadata.
func (*ServerTransportStream) Trailer ¶ added in v0.1.2
func (s *ServerTransportStream) Trailer() metadata.MD
Trailer returns the cached trailer metadata.