grpcrestserver

package module
v0.0.0-...-c2f85da Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2018 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package grpcrestserver serves the grpc and grpc-gateway rest handlers. This server extracts out all the boilerpalte code of creating a grpc/grpc-gateway server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunWith

func RunWith(opts Options)

RunWith starts both GRPC server and REST server with the given options.

Types

type AuthHelperFuncs

type AuthHelperFuncs struct {
	VerifyCredentialsFunc loginservice.VerifyCredentialsFunc
	GenerateTokenFunc     loginservice.GenerateTokenFunc
	ParseTokenFunc        loginservice.ParseTokenFunc
}

AuthHelperFuncs will be used by login service to verify credentials, generate a token, and parse the token.

type GRPCHandlerCallback

type GRPCHandlerCallback func(*grpc.Server)

GRPCHandlerCallback is a callback which will be called while it is creating GRPC server, this handler must be responsible for initializing the service implementations.

type Options

type Options struct {
	// GRPC server address eg. localhost:8889
	GRPCServerAddr string
	// REST server address eg. localhost:8888
	RESTServerAddr string
	// GRPC service handler callbacks
	GRPCServiceHandlers []GRPCHandlerCallback
	// REST endpoing handler callbacks
	RESTEndpointHandlers []RESTHandlerCallback
	// TLSOptions
	TLSOptions TLSOptions
	// AuthHelperFuncs which are used for login, authenticating each request.
	// These handlers are used at GRPC level. If you are fine using the default handlers for these keep it uninitialized.
	// Refer: loginservice.DefaultVerifyCredentialsFunc, loginservice.DefaultGenerateTokenFunc, loginservice.DefaultParseTokenFunc.
	AuthHelperFuncs AuthHelperFuncs
	// Swagger json file paths
	SwaggerJsonFilePaths []string
}

Options to start the both grpc server and grpc-gateway server.

type RESTHandlerCallback

type RESTHandlerCallback func(context.Context, *runtime.ServeMux, string, []grpc.DialOption) error

RESTHandlerCallback is a callback which will be called while it is creating REST server, this handler must be responsible for initializing the service implementations.

type TLSOptions

type TLSOptions struct {
	// Path to Certificate file
	CertFilePath string
	// Path to the Key file
	KeyFilePath string
}

TLSOptions to connect securely between grpc server and grpc gateway.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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