mongoclient

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const PUBLIC string = "PUBLIC"
View Source
const STATE string = "__STATE__"

Variables

This section is empty.

Functions

func GetMongoClientFromContext

func GetMongoClientFromContext(ctx context.Context) (types.IMongoClient, error)

GetMongoClientFromContext extracts mongo collections adapter struct from provided context.

func MongoClientInjectorMiddleware

func MongoClientInjectorMiddleware(collections types.IMongoClient) mux.MiddlewareFunc

MongoClientInjectorMiddleware will inject into request context the mongo collections.

func RetrieveUserBindingsAndRoles

func RetrieveUserBindingsAndRoles(logger *logrus.Entry, req *http.Request, env config.EnvironmentVariables) (types.User, error)

func RolesIDsFromBindings

func RolesIDsFromBindings(bindings []types.Binding) []string

func WithMongoClient

func WithMongoClient(ctx context.Context, mongoClient types.IMongoClient) context.Context

Types

type MongoClient

type MongoClient struct {
	// contains filtered or unexported fields
}

func NewMongoClient

func NewMongoClient(env config.EnvironmentVariables, logger *logrus.Logger) (*MongoClient, error)

NewMongoClient tries to setup a new MongoClient instance. The function returns a `nil` client if the environment variable `MongoDBUrl` is not specified.

func (*MongoClient) Disconnect

func (mongoClient *MongoClient) Disconnect() error

func (*MongoClient) FindMany

func (mongoClient *MongoClient) FindMany(ctx context.Context, collectionName string, query map[string]interface{}) ([]interface{}, error)

func (*MongoClient) FindOne

func (mongoClient *MongoClient) FindOne(ctx context.Context, collectionName string, query map[string]interface{}) (interface{}, error)

func (*MongoClient) RetrieveRoles

func (mongoClient *MongoClient) RetrieveRoles(ctx context.Context) ([]types.Role, error)

func (*MongoClient) RetrieveUserBindings

func (mongoClient *MongoClient) RetrieveUserBindings(ctx context.Context, user *types.User) ([]types.Binding, error)

func (*MongoClient) RetrieveUserRolesByRolesID

func (mongoClient *MongoClient) RetrieveUserRolesByRolesID(ctx context.Context, userRolesId []string) ([]types.Role, error)

Jump to

Keyboard shortcuts

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