server

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2023 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultAuth = "authkey"
	DefaultSign = "signkey"
)
View Source
const (
	AuthKey = "au"
)

Variables

View Source
var (
	InvalidAuthKey        = errors.New("invalid Authentication Key")
	InvalidTokenFormatErr = errors.New("invalid token format")
	MissingKeyErr         = errors.New("no Authentication Key provided")
)

Functions

func GetCreds

func GetCreds(conf *Config) (credentials.TransportCredentials, error)

Types

type Authenticator

type Authenticator interface {
	AuthenticateContext(context.Context) error
}

func NewAuthenticator

func NewAuthenticator(Skey, AKey string) Authenticator

type Config

type Config struct {
	Host    string `yaml:"host"`
	Port    uint   `yaml:"port"` //gRPC endpoint
	AuthKey string `yaml:"auth-key"`
	SignKey string `yaml:"sign-key"`
	DB      struct {
		Host     string `yaml:"host"`
		CertFile string `yaml:"certFile"`
	} `yaml:"db"`
	TLS struct {
		Enabled  bool   `yaml:"enabled"`
		CertFile string `yaml:"certFile"`
		CertKey  string `yaml:"certKey"`
		CAFile   string `yaml:"caFile"`
	} `tls:"tls,omitempty"`
}

func NewConfigFromFile

func NewConfigFromFile(path string) (*Config, error)

type Server

type Server struct {
	pb.UnimplementedExerciseStoreServer
	// contains filtered or unexported fields
}

func NewServer

func NewServer(conf *Config) (*Server, error)

func (*Server) AddCategory

func (s *Server) AddCategory(_ context.Context, request *pb.AddCategoryRequest) (*pb.ResponseStatus, error)

func (*Server) AddExercise

func (s *Server) AddExercise(_ context.Context, request *pb.AddExerciseRequest) (*pb.ResponseStatus, error)

func (*Server) DeleteCategory

func (s *Server) DeleteCategory(_ context.Context, request *pb.DeleteCategoryRequest) (*pb.ResponseStatus, error)

func (*Server) DeleteExercisesByTags

func (s *Server) DeleteExercisesByTags(_ context.Context, request *pb.DeleteExercisesByTagsRequest) (*pb.ResponseStatus, error)

func (*Server) GetCategories

func (s *Server) GetCategories(_ context.Context, _ *pb.Empty) (*pb.GetCategoriesResponse, error)

func (*Server) GetExercises

func (s *Server) GetExercises(_ context.Context, _ *pb.Empty) (*pb.GetExercisesShortResponse, error)

func (*Server) GetExercisesByCategory

func (s *Server) GetExercisesByCategory(_ context.Context, request *pb.GetExercisesByCategoryRequest) (*pb.GetExercisesShortResponse, error)

func (*Server) GetExercisesByTags

func (s *Server) GetExercisesByTags(_ context.Context, request *pb.GetExercisesByTagsRequest) (*pb.GetExercisesResponse, error)

func (*Server) GrpcOpts

func (s *Server) GrpcOpts(conf *Config) ([]grpc.ServerOption, error)

func (*Server) NewGRPCServer

func (s *Server) NewGRPCServer(opts ...grpc.ServerOption) *grpc.Server

func (*Server) UpdateCategory

func (s *Server) UpdateCategory(_ context.Context, request *pb.UpdateCategoryRequest) (*pb.ResponseStatus, error)

func (*Server) UpdateExercise

func (s *Server) UpdateExercise(_ context.Context, request *pb.UpdateExerciseRequest) (*pb.ResponseStatus, error)

func (*Server) UpdateStatus

func (s *Server) UpdateStatus(_ context.Context, _ *pb.Empty) (*pb.ResponseStatus, error)

Jump to

Keyboard shortcuts

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