server

package
v1.87.5 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2022 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultJSONMarshaler = &runtime.JSONPb{
		UnmarshalOptions: protojson.UnmarshalOptions{
			DiscardUnknown: true,
		},
	}

	DefaultServeMuxOptions = func(customHeaders ...string) []runtime.ServeMuxOption {
		return []runtime.ServeMuxOption{
			runtime.WithMarshalerOption(DefaultJSONMarshaler.ContentType(nil), DefaultJSONMarshaler),
			runtime.WithMarshalerOption(mimeWildcard, DefaultJSONMarshaler),
			runtime.WithMarshalerOption(runtime.MIMEWildcard, DefaultJSONMarshaler),
			runtime.WithIncomingHeaderMatcher(DefaultHeaderMatcher(customHeaders...)),
			runtime.WithOutgoingHeaderMatcher(runtime.DefaultHeaderMatcher),
		}
	}

	DefaultHeaderMatcher = func(customHeaders ...string) runtime.HeaderMatcherFunc {
		return func(header string) (string, bool) {
			for _, customHeader := range customHeaders {
				if strings.HasPrefix(strings.ToLower(header), customHeader) {
					return header, true
				}
			}
			return runtime.DefaultHeaderMatcher(header)
		}
	}
)

Functions

func CreateServer

func CreateServer(verifier *authz.TokenVerifier, authConfig authz.Config, lang language.Tag) *grpc.Server

func Serve

func Serve(ctx context.Context, server *grpc.Server, port string)

Types

type Gateway

type Gateway interface {
	RegisterGateway() GatewayFunc
	GatewayPathPrefix() string
}

type GatewayFunc

type GatewayFunc func(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) error

type GatewayHandler

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

func CreateGatewayHandler

func CreateGatewayHandler(config grpc_util.Config) *GatewayHandler

func (*GatewayHandler) RegisterGateway

func (g *GatewayHandler) RegisterGateway(ctx context.Context, gateway Gateway)

RegisterGateway registers a handler (Gateway interface) on defined port Gateway interface may be extended with optional implementation of interfaces (gatewayCustomServeMuxOptions, ...)

func (*GatewayHandler) RegisterHandler

func (g *GatewayHandler) RegisterHandler(prefix string, handler http.Handler)

func (*GatewayHandler) Serve

func (g *GatewayHandler) Serve(ctx context.Context)

type Server

type Server interface {
	Gateway
	RegisterServer(*grpc.Server)
	AppName() string
	MethodPrefix() string
	AuthMethods() authz.MethodMapping
}

type ValidationFunction

type ValidationFunction func(ctx context.Context) error

type Validator

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

func NewValidator

func NewValidator(validations map[string]ValidationFunction) *Validator

func (*Validator) Healthz

func (v *Validator) Healthz(_ context.Context, e *empty.Empty) (*empty.Empty, error)

func (*Validator) Ready

func (v *Validator) Ready(ctx context.Context, e *empty.Empty) (*empty.Empty, error)

func (*Validator) Validate

func (v *Validator) Validate(ctx context.Context, _ *empty.Empty) (*structpb.Struct, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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