Documentation ¶
Index ¶
- Constants
- Variables
- func WithDebug() func(*Service) error
- func WithGRPCPort(port int) func(*Service) error
- func WithGRPCServer(server *grpc.Server) func(*Service) error
- func WithGRPCServerOptions(opts ...grpc.ServerOption) func(*Service) error
- func WithGatewayHandlers(handlers ...func(context.Context, *runtime.ServeMux, *grpc.ClientConn) error) func(*Service) error
- func WithHTTPMiddleware(handlers ...httpHandler) func(*Service) error
- func WithInsecureSkipVerify() func(*Service) error
- func WithMaxRecieveSize(size int) func(*Service) error
- func WithMaxSendSize(size int) func(*Service) error
- func WithPort(port int) func(*Service) error
- func WithServerMuxOptions(opts ...runtime.ServeMuxOption) func(*Service) error
- func WithStreamInterceptors(interceptors ...grpc.StreamServerInterceptor) func(*Service) error
- func WithTLSDisabled() func(*Service) error
- func WithUnaryInterceptors(interceptors ...grpc.UnaryServerInterceptor) func(*Service) error
- type Option
- type Service
- func (s *Service) AddGatewayHandlers(handlers ...func(context.Context, *runtime.ServeMux, *grpc.ClientConn) error) error
- func (s *Service) AddHTTPMiddleware(handler httpHandler)
- func (s *Service) AddKeyPair(publicCert, privateKey []byte) error
- func (s *Service) AddKeyPairFromFiles(publicCertFile, privateKeyFile string) error
- func (s *Service) AddStreamInterceptors(interceptors ...grpc.StreamServerInterceptor) error
- func (s *Service) AddUnaryInterceptors(interceptors ...grpc.UnaryServerInterceptor) error
- func (s *Service) AppendCertsFromPEM(rootCA []byte) error
- func (s *Service) GRPC() *grpc.Server
- func (s *Service) GetCertificate() (tls.Certificate, error)
- func (s *Service) PrintDebug()
- func (s *Service) Serve(ctx context.Context) error
- func (s *Service) Shutdown(ctx context.Context) error
- func (s *Service) WithOptions(opts ...Option) error
Constants ¶
View Source
const ( // EnvPort is the primary port to serve everything on. EnvPort = "PORT" // EnvGRPCPort serves GRPC on a separate port EnvGRPCPort = "GRPC_PORT" // EnvDebug enables debug output EnvDebug = "SERVICE_DEBUG" // EnvInsecureVerifySkip disables TLS verification EnvInsecureVerifySkip = "INSECURE_VERIFY_SKIP" // EnvTLSDisabled will disable TLS (will only support HTTP/1 requests) EnvTLSDisabled = "TLS_DISABLED" // EnvCorsEnable env var (default: false) EnvCorsEnable = "CORS_ENABLE" // EnvCorsDebug env var (default: false) EnvCorsDebug = "CORS_DEBUG" // EnvCorsAllowedOrigins env var EnvCorsAllowedOrigins = "CORS_ALLOWED_ORIGINS" // EnvCorsAllowedMethods env var EnvCorsAllowedMethods = "CORS_ALLOWED_METHODS" // EnvCorsAllowedHeaders env var EnvCorsAllowedHeaders = "CORS_ALLOWED_HEADERS" )
Variables ¶
View Source
var ( // ErrInvalidPort error message ErrInvalidPort = errors.New("invalid port %d") ErrInvalidRecieveSize = errors.New("invalid max recieve size %d") ErrInvalidSendSize = errors.New("invalid max send size %d") ErrMissingGrpcServerOptions = errors.New("invalid grpc server options: missing") ErrMissingGrpcUnaryInterceptors = errors.New("invalid grpc unary interceptors: missing") ErrMissingGrpcStreamInterceptors = errors.New("invalid grpc stream interceptors: missing") ErrMissingGatewayHandlers = errors.New("invalid grpc gateway handlers: missing") ErrWithGRPCServerIsNil = errors.New("invalid grpc server: is nil ") ErrServeGRPCNotYetDefined = errors.New("service serve gprc not yet defined (has pb.RegisterYourServer(service.GRPC(), ...) been called?)") ErrDisableTLSCertsMissingGRPCPort = errors.New("invalid grpc port: must set GRPC port when disabling TLS (use environment " + EnvGRPCPort + " or WithGRPCPort(port)") // 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") )
Functions ¶
func WithGRPCPort ¶ added in v0.2.2
func WithGRPCServerOptions ¶ added in v0.2.2
func WithGRPCServerOptions(opts ...grpc.ServerOption) func(*Service) error
func WithGatewayHandlers ¶ added in v0.2.2
func WithHTTPMiddleware ¶ added in v0.2.2
func WithInsecureSkipVerify ¶ added in v0.2.2
func WithMaxRecieveSize ¶ added in v0.2.2
func WithMaxSendSize ¶ added in v0.2.2
func WithServerMuxOptions ¶ added in v0.2.2
func WithServerMuxOptions(opts ...runtime.ServeMuxOption) func(*Service) error
func WithStreamInterceptors ¶ added in v0.2.2
func WithStreamInterceptors(interceptors ...grpc.StreamServerInterceptor) func(*Service) error
func WithTLSDisabled ¶ added in v0.2.2
func WithUnaryInterceptors ¶ added in v0.2.2
func WithUnaryInterceptors(interceptors ...grpc.UnaryServerInterceptor) func(*Service) error
Types ¶
type Service ¶
type Service struct { HTTP *http.ServeMux Router *chi.Mux CertPool *x509.CertPool PublicCert []byte PrivateKey []byte // contains filtered or unexported fields }
func (*Service) AddGatewayHandlers ¶ added in v0.2.2
func (*Service) AddHTTPMiddleware ¶ added in v0.2.0
func (s *Service) AddHTTPMiddleware(handler httpHandler)
func (*Service) AddKeyPair ¶
AddKeyPair allows for direct setting of cert/keys
func (*Service) AddKeyPairFromFiles ¶
AddKeyPairFromFiles allows for setting cert/key from files
func (*Service) AddStreamInterceptors ¶ added in v0.2.2
func (s *Service) AddStreamInterceptors(interceptors ...grpc.StreamServerInterceptor) error
func (*Service) AddUnaryInterceptors ¶ added in v0.2.2
func (s *Service) AddUnaryInterceptors(interceptors ...grpc.UnaryServerInterceptor) error
func (*Service) AppendCertsFromPEM ¶
AppendCertsFromPEM support direct setting of rootCA
func (*Service) GetCertificate ¶
func (s *Service) GetCertificate() (tls.Certificate, error)
GetCertificate is a helper for pulling tls.Certificate from provided cert/key
func (*Service) PrintDebug ¶ added in v0.2.2
func (s *Service) PrintDebug()
func (*Service) WithOptions ¶ added in v0.2.2
Source Files ¶
Click to show internal directories.
Click to hide internal directories.