grpcgateway

package
v2.0.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2025 License: Apache-2.0 Imports: 27 Imported by: 1

Documentation

Overview

Package grpcgateway utilizes the global gogoproto registry to create dynamic query handlers on net/http's mux router.

Header `x-cosmos-block-height` allows you to specify a height for the query.

Requests that do not have a dynamic handler registered will be routed to the canonical gRPC-Gateway mux.

Index

Constants

View Source
const GRPCBlockHeightHeader = "x-cosmos-block-height"

GRPCBlockHeightHeader is the gRPC header for block height.

View Source
const MaxBodySize = 1 << 20 // 1 MB
View Source
const ServerName = "grpc-gateway"

Variables

This section is empty.

Functions

func CustomGRPCHeaderMatcher

func CustomGRPCHeaderMatcher(key string) (string, bool)

CustomGRPCHeaderMatcher for mapping request headers to GRPC metadata. HTTP headers that start with 'Grpc-Metadata-' are automatically mapped to gRPC metadata after removing prefix 'Grpc-Metadata-'. We can use this CustomGRPCHeaderMatcher if headers don't start with `Grpc-Metadata-`

Types

type CfgOption

type CfgOption func(*Config)

func Disable

func Disable() CfgOption

Disable the grpc server by default (default enabled).

func OverwriteDefaultConfig

func OverwriteDefaultConfig(newCfg *Config) CfgOption

OverwriteDefaultConfig overwrites the default config with the new config.

type Config

type Config struct {
	// Enable defines if the gRPC-Gateway should be enabled.
	Enable bool `mapstructure:"enable" toml:"enable" comment:"Enable defines if the gRPC-Gateway should be enabled."`

	// Address defines the address the gRPC-Gateway server binds to.
	Address string `mapstructure:"address" toml:"address" comment:"Address defines the address the gRPC-Gateway server binds to."`
}

func DefaultConfig

func DefaultConfig() *Config

type Server

type Server[T transaction.Tx] struct {
	GRPCGatewayRouter *runtime.ServeMux
	// contains filtered or unexported fields
}

func New

func New[T transaction.Tx](
	logger log.Logger,
	config server.ConfigMap,
	ir jsonpb.AnyResolver,
	appManager appmanager.AppManager[T],
	cfgOptions ...CfgOption,
) (*Server[T], error)

New creates a new gRPC-Gateway server.

func NewWithConfigOptions

func NewWithConfigOptions[T transaction.Tx](opts ...CfgOption) *Server[T]

NewWithConfigOptions creates a new gRPC-gateway server with the provided config options.

func (*Server[T]) Config

func (s *Server[T]) Config() any

func (*Server[T]) Name

func (s *Server[T]) Name() string

func (*Server[T]) Start

func (s *Server[T]) Start(ctx context.Context) error

func (*Server[T]) Stop

func (s *Server[T]) Stop(ctx context.Context) error

Jump to

Keyboard shortcuts

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