{"modulePath":"github.com/dtop/janus","version":"v0.0.0-20190429074113-98b9f36d39c6","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package basic\n\n## Variables\n\n```go\nvar (\n\t// ErrNotAuthorized is used when the the access is not permisted\n\tErrNotAuthorized = errors.New(http.StatusUnauthorized, \"not authorized\")\n\t// ErrUserNotFound is used when an user is not found\n\tErrUserNotFound = errors.New(http.StatusNotFound, \"user not found\")\n\t// ErrUserExists is used when an user already exists\n\tErrUserExists = errors.New(http.StatusNotFound, \"user already exists\")\n\t// ErrInvalidAdminRouter is used when an invalid admin router is given\n\tErrInvalidAdminRouter = errors.New(http.StatusNotFound, \"invalid admin router given\")\n)\n```\n\n## Functions\n\n```go\nfunc NewBasicAuth(repo Repository) func(http.Handler) http.Handler\n```\nNewBasicAuth is a HTTP basic auth middleware\n\n## Types\n\n```go\ntype Handler struct {\n\t// contains filtered or unexported fields\n}\n```\nHandler is the api rest handlers\n\n```go\nfunc NewHandler(repo Repository) *Handler\n```\nNewHandler creates a new instance of Handler\n\n```go\nfunc (c *Handler) Create() http.HandlerFunc\n```\nCreate is the create handler\n\n```go\nfunc (c *Handler) Delete() http.HandlerFunc\n```\nDelete is the delete handler\n\n```go\nfunc (c *Handler) Index() http.HandlerFunc\n```\nIndex is the find all handler\n\n```go\nfunc (c *Handler) Show() http.HandlerFunc\n```\nShow is the find by handler\n\n```go\nfunc (c *Handler) Update() http.HandlerFunc\n```\nUpdate is the update handler\n\n```go\ntype InMemoryRepository struct {\n\tsync.RWMutex\n\t// contains filtered or unexported fields\n}\n```\nInMemoryRepository represents a in memory repository\n\n```go\nfunc NewInMemoryRepository() *InMemoryRepository\n```\nNewInMemoryRepository creates a in memory repository\n\n```go\nfunc (r *InMemoryRepository) Add(user *User) error\n```\nAdd adds an user to the repository\n\n```go\nfunc (r *InMemoryRepository) FindAll() ([]*User, error)\n```\nFindAll fetches all the users available\n\n```go\nfunc (r *InMemoryRepository) FindByUsername(username string) (*User, error)\n```\nFindByUsername find an user by username\n\n```go\nfunc (r *InMemoryRepository) Remove(username string) error\n```\nRemove removes an user from the repository\n\n```go\ntype MongoRepository struct {\n\t// contains filtered or unexported fields\n}\n```\nMongoRepository represents a mongodb repository\n\n```go\nfunc NewMongoRepository(session *mgo.Session) (*MongoRepository, error)\n```\nNewMongoRepository creates a mongo API definition repo\n\n```go\nfunc (r *MongoRepository) Add(user *User) error\n```\nAdd adds an user to the repository\n\n```go\nfunc (r *MongoRepository) FindAll() ([]*User, error)\n```\nFindAll fetches all the API definitions available\n\n```go\nfunc (r *MongoRepository) FindByUsername(username string) (*User, error)\n```\nFindByUsername find an user by username\n\n```go\nfunc (r *MongoRepository) Remove(username string) error\n```\nRemove an user from the repository\n\n```go\ntype Repository interface {\n\tFindAll() ([]*User, error)\n\tFindByUsername(username string) (*User, error)\n\tAdd(user *User) error\n\tRemove(username string) error\n}\n```\nRepository represents an user repository\n\n```go\ntype User struct {\n\tUsername string `json:\"username\"`\n\tPassword string `json:\"password\"`\n}\n```\nUser represents an user\n\n","path":"github.com/dtop/janus/pkg/plugin/basic","name":"basic","synopsis":"","isRedistributable":true}
