Documentation ¶
Index ¶
- func CheckNotFound(err error) bool
- func CheckRemoved(err error) bool
- func NewErrNotFound(msg string) error
- func NewErrRemoved(msg string) error
- type Authenticator
- type Backend
- type Doc
- type DocStore
- type ErrNotFound
- type ErrRemoved
- type FileStore
- type Group
- type GroupStore
- type Policy
- type PolicyStore
- type TextIndex
- type User
- type UserStore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckNotFound ¶
CheckNotFound is a helper function for determining if an error type is actually an ErrNotFound.
func CheckRemoved ¶
CheckRemoved is a helper function for determining if an error type is actually an ErrRemoved.
func NewErrNotFound ¶
NewErrNotFound returns a new ErrNotFound as a normal error containing the given message.
func NewErrRemoved ¶
NewErrRemoved returns a new ErrRemoved as a normal error containing the given message.
Types ¶
type Authenticator ¶
type Authenticator interface {
Authenticate(ctx context.Context, email, token string) (User, error)
}
An Authenticator knows how to authenticate user credentials.
type Backend ¶
type Backend interface { DocStore UserStore GroupStore }
A Backend is an aggregation of almost all docshelf store interfaces.
type Doc ¶
type Doc struct { ID string `json:"id"` Path string `json:"path"` Title string `json:"title"` IsDir bool `json:"isDir"` Content string `json:"content,omitempty"` Policy *Policy `json:"policy"` Tags []string `json:"tags"` CreatedBy string `json:"createdBy"` UpdatedBy string `json:"updatedBy"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` }
A Doc is a full docshelf document. This includes metadata as well as content.
func (Doc) ContentString ¶
ContentString returns a Doc's content as a string.
type DocStore ¶
type DocStore interface { GetDoc(ctx context.Context, path string) (Doc, error) ListDocs(ctx context.Context, query string, tags ...string) ([]Doc, error) PutDoc(ctx context.Context, doc Doc) (string, error) TagDoc(ctx context.Context, path string, tags ...string) error RemoveDoc(ctx context.Context, path string) error }
A DocStore knows how to store and retrieve docshelf documents.
type ErrNotFound ¶
type ErrNotFound struct {
// contains filtered or unexported fields
}
ErrNotFound is a special error type for signaling that a requested entity doesn't exist.
func (ErrNotFound) Error ¶
func (e ErrNotFound) Error() string
Error implements the Error interface for ErrNotFound. Default messaging is used if not supplied.
type ErrRemoved ¶
type ErrRemoved struct {
// contains filtered or unexported fields
}
ErrRemoved is a special error type for signaling that a requested entity has been removed.
func (ErrRemoved) Error ¶
func (e ErrRemoved) Error() string
Error implements the Error interface for ErrRemoved. Default messaging is used if not supplied.
type FileStore ¶
type FileStore interface { ReadFile(path string) ([]byte, error) WriteFile(path string, data []byte) error RemoveFile(path string) error ListDir(path string) ([]string, error) }
A FileStore knows how to store and retrieve docshelf document contents.
type Group ¶
type Group struct { ID string `json:"id"` Name string `json:"name"` Users []string `json:"users"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` }
A Group is collection of Users for the purposes of granting access.
type GroupStore ¶
type GroupStore interface { GetGroup(ctx context.Context, id string) (Group, error) PutGroup(ctx context.Context, group Group) (string, error) RemoveGroup(ctx context.Context, id string) error }
A GroupStore knows how to store and retrieve docshelf Groups.
type Policy ¶
type Policy struct { ID string `json:"id"` Users []string `json:"users"` Groups []string `json:"groups"` ReadOnly bool `json:"readOnly"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` }
An Policy defines the users and groups that have access to a particular file path.
type PolicyStore ¶
type PolicyStore interface { GetPolicy(ctx context.Context, id string) (Policy, error) PutPolicy(ctx context.Context, policy Policy) (string, error) RemovePolicy(ctx context.Context, id string) (string, error) }
A PolicyStore knows how to store and retrieve docshelf Policies.
type TextIndex ¶
type TextIndex interface { Index(ctx context.Context, doc Doc) error Search(ctx context.Context, term string) ([]string, error) }
An TextIndex knows how to index and search docshelf documents.
type User ¶
type User struct { ID string `json:"id"` Email string `json:"email"` Name string `json:"name"` Token string `json:"token"` Groups []string `json:"groups"` Pinned []string `json:"pinned"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` DeletedAt *time.Time `json:"deletedAt"` }
A User is the identity of anyone using docshelf.
type UserStore ¶
type UserStore interface { GetUser(ctx context.Context, id string) (User, error) // GetEmail(ctx context.Context, email string) (User, error) ListUsers(ctx context.Context) ([]User, error) PutUser(ctx context.Context, user User) (string, error) RemoveUser(ctx context.Context, id string) error }
A UserStore knows how to store and retrieve docshelf users.