Documentation ¶
Overview ¶
Package server contains utilities for managing different kinds of servers. Currently supports HTTP & gRPC.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidTLSHost = errors.New("invalid tls host")
ErrInvalidTLSHost is the error given when an inbound TLS request does not match the server's host policy.
Functions ¶
func DialGRPC ¶ added in v1.4.0
func DialGRPC(ctx context.Context, addr string, opts ...grpc.DialOption) (*grpc.ClientConn, error)
DialGRPC connects to a desired gRPC server, applying default options and registering interceptors.
Types ¶
type GRPCOption ¶
type GRPCOption func(c *grpcConfig)
The GRPCOption type is a function that modifies a field on the gRPC configuration.
func WithServerOptions ¶
func WithServerOptions(opts ...grpc.ServerOption) GRPCOption
WithServerOptions configures the options to use when calling grpc.NewServer.
func WithService ¶
func WithService(svc GRPCService) GRPCOption
WithService adds a GRPCService implementation whose Register method will be called once the server is started.
type GRPCService ¶
The GRPCService interface describes types that can be registered to a gRPC service. Each service implementation should have a Register method that registers the type to the gRPC server.
type HTTPOption ¶
type HTTPOption func(c *httpConfig)
The HTTPOption type represents a server option that can be used to modify the HTTP server configuration.
func WithAllowedHosts ¶
func WithAllowedHosts(hosts ...string) HTTPOption
WithAllowedHosts sets hosts that are allowed to make TLS requests.
func WithHandler ¶
func WithHandler(r *mux.Router) HTTPOption
WithHandler sets the server's handler to the one provided.
func WithSecurity ¶
func WithSecurity(flag bool) HTTPOption
WithSecurity enables/disables the server's SSL features.
func WithTLSCache ¶
func WithTLSCache(dir string) HTTPOption
WithTLSCache determines the location on the filesystem that TLS certificates will be cached.