httpgateway

package
v0.68.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2021 License: MIT Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BinaryCodec

type BinaryCodec struct{}

BinaryCodec is a encoding.Codec that acts as an identity transform for raw binary inputs and outputs.

When marshaling, it simply returns the input byte slice. When unmarshaling, it expects a pointer to a byte slice as an input, so it can point it at the raw byte slice.

func (*BinaryCodec) Marshal

func (bc *BinaryCodec) Marshal(value interface{}) ([]byte, error)

func (*BinaryCodec) Name

func (bc *BinaryCodec) Name() string

func (*BinaryCodec) Unmarshal

func (bc *BinaryCodec) Unmarshal(data []byte, value interface{}) error

type Mux

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

Mux serves HTTP and Websocket endpoints that re-routes

func New

func New(serv *grpc.Server, cc *grpc.ClientConn, opts ...MuxOption) *Mux

New creates a new Mux that loads all registered services in the gRPC server and sets up corresponding routes.

Unary requests are set up as basic HTTP/1.1 requests. Streaming requests are set up as Websocket connections.

func (*Mux) ListenAndServeHTTP

func (m *Mux) ListenAndServeHTTP(listenAddr string) error

ListenAndServeHTTP listens on the specified address, and forwards requests to the gRPC server.

func (*Mux) ServeHTTP

func (m *Mux) ServeHTTP(l net.Listener) error

ServeHTTP serves HTTP on the provided listener, forwarding requests to the gRPC server.

type MuxOption

type MuxOption func(*Mux)

MuxOption configures the mux.

func WithCORSEnabled

func WithCORSEnabled(enabled bool) MuxOption

WithCORSEnabled sets whether CORS is enabled.

func WithRouter

func WithRouter(router *mux.Router) MuxOption

WithRouter provides an alternative mux.Router to use.

func WithUpgrader

func WithUpgrader(upgrader websocket.Upgrader) MuxOption

WithUpgrader provides an alternative websocket.Upgrader to use.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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