standard

package
v1.96.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListenAndServe

func ListenAndServe(runCtx context.Context, handler http.Handler, port string) <-chan struct{}

ListenAndServe starts the server

func ListenAndServeGRPC

func ListenAndServeGRPC(runCtx context.Context, grpcServer *grpc.Server, listenAddress string, gwServer *http.Server) <-chan struct{}

ListenAndServeGRPC starts both a GRPC server and a RESTful gateway server

func ListenAndServeMetrics added in v1.96.0

func ListenAndServeMetrics(runCtx context.Context, port string) <-chan struct{}

ListenAndServeMetrics serves the Prometheus metrics at /metrics on port until runCtx is canceled. The returned channel closes when the server has stopped.

Use a port that no Kubernetes service exposes, and let Prometheus scrape the pod through the prometheus.io/port annotation. Metrics on the application port are published with it by the ingress.

func Main

func Main(serviceMain MainFunction, svcName string, options ...MainOption)

Main is a wrapper function over main - it handles the typical tasks like starting DB connection, handling OS signals, etc.

func NewGRPCGatewayServer

func NewGRPCGatewayServer(
	server *grpc.Server,
	grpcPort, gatewayPort string,
	corsOptions cors.Options,
	handlerRegisterFunctions []func(context.Context, *runtime.ServeMux, *grpc.ClientConn) error,
	muxOptions ...runtime.ServeMuxOption,
) (*http.Server, error)

NewGRPCGatewayServer creates a gRPC-Gateway server with given grpc handler registration functions. It serves no metrics; use ListenAndServeMetrics to serve them on a separate port. muxOptions are passed to runtime.NewServeMux, e.g. runtime.WithIncomingHeaderMatcher to forward custom headers as gRPC metadata.

func WithPathPrefixStrip added in v1.92.0

func WithPathPrefixStrip(prefix string, h http.Handler) http.Handler

WithPathPrefixStrip returns a handler that strips prefix from request URLs when they match the given path prefix (exact match or prefix + "/"). If prefix is empty or doesn't match, the original request is passed through unchanged.

Types

type MainFunction

type MainFunction func(context.Context, string) <-chan struct{}

type MainOption

type MainOption func(context.Context)

func WithPostgres

func WithPostgres(opts *db.ConnectionOptions) MainOption

Jump to

Keyboard shortcuts

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