grpcserver

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMetadataMissing          = errors.New("missing metadata")
	ErrAuthHeaderMissing        = errors.New("missing authorization header")
	ErrAuthHeaderInvalid        = errors.New("invalid authorization header format")
	ErrAuthTypeUnsupported      = errors.New("unsupported authorization type")
	ErrAccessTokenInvalid       = errors.New("invalid access token")
	ErrTLSCertNotFull           = errors.New("TLS cert or key file is missing")
	ErrCannotReadTLSCert        = errors.New("cannot read TLS cert or key file")
	ErrSwaggerPrefixMissing     = errors.New("missing swagger prefix")
	ErrCannotCreateListener     = errors.New("cannot create listener")
	ErrCannotStartServer        = errors.New("cannot start GRPC server")
	ErrCannotStartGatewayServer = errors.New("cannot start HTTP gateway server")
	ErrCannotCreateStatikFS     = errors.New("cannot create statik fs")
	ErrCannotAddClientTLS       = errors.New("cannot add client TLS")
)

Functions

func AuthorizeUser

func AuthorizeUser(ctx context.Context, tokenMaker core.TokenMakerComponent) (*token.Payload, error)

func GrpcLogger

func GrpcLogger(
	ctx context.Context,
	req interface{},
	info *grpc.UnaryServerInfo,
	handler grpc.UnaryHandler,
) (resp interface{}, err error)

func HttpLogger

func HttpLogger(handler http.Handler) http.Handler

func NewServer

func NewServer(id string) *grpcServer

Types

type Metadata

type Metadata struct {
	UserAgent string
	ClientIP  string
}

func ExtractMetadata

func ExtractMetadata(ctx context.Context) *Metadata

type ResponseRecorder

type ResponseRecorder struct {
	http.ResponseWriter
	StatusCode int
	Body       []byte
}

func (*ResponseRecorder) Write

func (rec *ResponseRecorder) Write(body []byte) (int, error)

func (*ResponseRecorder) WriteHeader

func (rec *ResponseRecorder) WriteHeader(statusCode int)

Jump to

Keyboard shortcuts

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