Documentation ¶
Overview ¶
Package grpcserver provides the implementation of a gRPC server with support for both HTTP/1.1 and HTTP/2. It handles user authentication, file transfer, and key-value storage operations through the corresponding gRPC services.
This package offers both standard and TLS-encrypted server configurations, customizable through the provided configuration structure. It supports CORS and includes JWT-based authentication interceptors for enhanced security.
Index ¶
- func NewCORS() *cors.Cors
- func NewError(err error) error
- type Error
- type GRPC
- type GRPCServer
- func (s *GRPCServer) GetHost() string
- func (s *GRPCServer) GetPort() int
- func (s *GRPCServer) Listen(_ *settings.Settings) (*http.Server, error)
- func (s *GRPCServer) ListenAndServe(cfg *settings.Settings) error
- func (s *GRPCServer) ListenAndServeTLS(cfg *settings.Settings) error
- func (s *GRPCServer) ListenTLS(cfg *settings.Settings) (*http.Server, error)
- func (s *GRPCServer) LoadTLS(cfg *settings.Settings) (*tls.Config, error)
- func (s *GRPCServer) SetHost(h string) *GRPCServer
- func (s *GRPCServer) SetPort(p int) *GRPCServer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type GRPC ¶
type GRPC interface { // SetHost sets the server's hostname. SetHost(h string) *GRPCServer // SetPort sets the server's port number. SetPort(p int) *GRPCServer // GetHost retrieves the configured host. GetHost() string // GetPort retrieves the configured port. GetPort() int // ListenAndServe starts the server without TLS. ListenAndServe(cfg *settings.Settings) error // ListenAndServeTLS starts the server with TLS. ListenAndServeTLS(cfg *settings.Settings) error // LoadTLS loads TLS certificates and returns a TLS configuration. LoadTLS(cfg *settings.Settings) (*tls.Config, error) // ListenTLS creates a TLS-enabled HTTP server. ListenTLS(cfg *settings.Settings) (*http.Server, error) }
GRPC defines the contract for setting up and running a gRPC server.
type GRPCServer ¶
type GRPCServer struct {
// contains filtered or unexported fields
}
GRPCServer implements the Interface and is responsible for managing the gRPC services.
func NewGRPCServer ¶
func NewGRPCServer() *GRPCServer
NewGRPCServer creates a new instance of GRPCServer with default logger settings.
func SetupGRPC ¶
func SetupGRPC(host string, port int) *GRPCServer
SetupGRPC is a helper function to configure a new GRPCServer.
func (*GRPCServer) GetHost ¶
func (s *GRPCServer) GetHost() string
GetHost returns the host configured for the server.
func (*GRPCServer) GetPort ¶
func (s *GRPCServer) GetPort() int
GetPort returns the port configured for the server.
func (*GRPCServer) ListenAndServe ¶
func (s *GRPCServer) ListenAndServe(cfg *settings.Settings) error
ListenAndServe starts the server without TLS encryption.
func (*GRPCServer) ListenAndServeTLS ¶
func (s *GRPCServer) ListenAndServeTLS(cfg *settings.Settings) error
ListenAndServeTLS starts the server with TLS encryption.
func (*GRPCServer) LoadTLS ¶
LoadTLS loads and returns a TLS configuration using server certificates.
func (*GRPCServer) SetHost ¶
func (s *GRPCServer) SetHost(h string) *GRPCServer
SetHost sets the host for the server.
func (*GRPCServer) SetPort ¶
func (s *GRPCServer) SetPort(p int) *GRPCServer
SetPort sets the port for the server.