Documentation
¶
Index ¶
- Variables
- func ErrReplacer(err error, replacers ...interface{}) error
- type Grpc
- type Service
- func (s *Service) AddGatewayHandler(...) error
- func (s *Service) AddHTTPMiddleware(handler func(http.Handler) http.Handler)
- func (s *Service) AddKeyPair(publicCert, privateKey []byte) error
- func (s *Service) AddKeyPairFromFiles(publicCertFile, privateKeyFile string) error
- func (s *Service) AppendCertsFromPEM(rootCA []byte) error
- func (s *Service) EnableInsecure()
- func (s *Service) GetCertificate() (tls.Certificate, error)
- func (s *Service) GracefulShutdown(ctx context.Context) error
- func (s *Service) GrpcServer() *grpc.Server
- func (s *Service) Serve() error
- func (s *Service) Shutdown() error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidHost error message ErrInvalidHost = errors.New("Host wasn't provided or is invalid") // ErrInvalidPort error message ErrInvalidPort = errors.New("Invalid port %d") // ErrAddingRootCA error message ErrAddingRootCA = errors.New("Unable to add Root CA to cert pool, invalid cert.") // ErrMissingPublicCert error message ErrMissingPublicCert = errors.New("Missing public cert. Fix by using: service.AddKeyPair or server.AddKeyPairFromFiles") // ErrMissingPrivateKey error message ErrMissingPrivateKey = errors.New("Missing private key. Fix by using: service.AddKeyPair or server.AddKeyPairFromFiles") // ErrAddKeyPairPublicCertIsNil error message ErrAddKeyPairPublicCertIsNil = errors.New("Unable to add key pair, public cert is nil") // ErrAddKeyPairPrivateKeyIsNil error message ErrAddKeyPairPrivateKeyIsNil = errors.New("Unable to add key pair, private key is nil") // ErrAddKeyPairFromFilePublicCertEmpty error message ErrAddKeyPairFromFilePublicCertEmpty = errors.New("Unable to add key pair from files, public cert is empty") // ErrAddKeyPairFromFilePublicCertNotFound error message ErrAddKeyPairFromFilePublicCertNotFound = errors.New("Unable to add key pair, public cert not found at %s") // ErrAddKeyPairPrivateKeyEmpty error message ErrAddKeyPairPrivateKeyEmpty = errors.New("Unable to add key pair, private key is nil") // ErrAddKeyPairFromFilePrivateKeyNotFound error message ErrAddKeyPairFromFilePrivateKeyNotFound = errors.New("Unable to add key pair, private key not found at %s") // ErrGatewayHandlerIsNil error message ErrGatewayHandlerIsNil = errors.New("Gateway entrypoint handler nil") )
Functions ¶
func ErrReplacer ¶
ErrReplacer allows for static errors to have dynamic values
Types ¶
type Grpc ¶
type Grpc struct {
MaxReceiveSize int
MaxSendSize int
ServerOptions []grpc.ServerOption
UnaryInterceptors []grpc.UnaryServerInterceptor
StreamInterceptors []grpc.StreamServerInterceptor
Server *grpc.Server
}
Grpc holds settings and server
func (*Grpc) AddOptions ¶
func (g *Grpc) AddOptions(opts ...grpc.ServerOption)
AddOptions is an exposed method to append options
func (*Grpc) AddStreamInterceptors ¶
func (g *Grpc) AddStreamInterceptors(interceptors ...grpc.StreamServerInterceptor)
AddStreamInterceptors is an exposed method to append stream interceptors
func (*Grpc) AddUnaryInterceptors ¶
func (g *Grpc) AddUnaryInterceptors(interceptors ...grpc.UnaryServerInterceptor)
AddUnaryInterceptors is an exposed method to append unary interceptors
type Service ¶
type Service struct {
Port int
CertPool *x509.CertPool
PublicCert []byte
PrivateKey []byte
Grpc *Grpc
Mux *http.ServeMux
Router *chi.Mux
// contains filtered or unexported fields
}
Service holds the top level settings and references
func (*Service) AddGatewayHandler ¶
func (s *Service) AddGatewayHandler(handler ...func(context.Context, *runtime.ServeMux, string, []grpc.DialOption) error) error
AddGatewayHandler allows for adding for http(s) fallbacks
func (*Service) AddHTTPMiddleware ¶ added in v0.2.0
AddHTTPMiddleware allows for adding middleware to http(s) specifically
func (*Service) AddKeyPair ¶
AddKeyPair allows for direct setting of cert/keys
func (*Service) AddKeyPairFromFiles ¶
AddKeyPairFromFiles allows for setting cert/key from files
func (*Service) AppendCertsFromPEM ¶
AppendCertsFromPEM support direct setting of rootCA
func (*Service) EnableInsecure ¶
func (s *Service) EnableInsecure()
EnableInsecure is a setter for enabling the insecure flag
func (*Service) GetCertificate ¶
func (s *Service) GetCertificate() (tls.Certificate, error)
GetCertificate is a helper for pulling tls.Certificate from provided cert/key
func (*Service) GracefulShutdown ¶
GracefulShutdown attempts to gracefully shutdown server given a context timeout
func (*Service) GrpcServer ¶
GrpcServer creates and returns the server after applying ServerOptions