# README
cmd/server
dash annotations server.
# Functions
Authenticated is a middleware that checks for authentication in the request Authentication is identified using the laravel_session cookie.
EntryCreate creates a new entry with the current user as author.
EntryDelete removes an annotation entirely from dash.
EntryGet returns the informations necessary for dash to display an annotation.
EntryList returns all public/ team/ and own entries for a requested identifier.
EntryRemoveFromPublic allows an moderator to hide a public annotation.
EntryRemoveFromTeams allows a team moderator to hide an annotation from the team.
EntrySave updates an existing entry.
EntryVote registers and updates the vote from the current user for a given annotation.
MaybeAuthenticated is a middleware that tries to authenticate a user by the session.
NewRootContext returns a context with the database set.
TeamCreate tries to create a new team with a given name inside the database.
TeamJoin tries to add the current user to the requested team.
TeamLeave removes the current user from the requested team.
TeamList returns a list of all teams the current user is a member|moderator of.
TeamListMember allows moderators to list all members of a requested team.
TeamRemoveMember allows a moderator to remove a member from a team.
TeamSetAccessKey allows moderators to change the access key for a given team.
TeamSetRole changes the role of the target user to the requested role.
UserChangeEmail changes the email address of the current user.
UserChangePassword changes the encrypted password of the current user.
UserLogin tries to authenticate an existing user using username/ password combination.
UserLogout destroys the session of the current user.
UserRegister tries to create a new user inside the dash annotations database.
WithEntry is a middleware that extracts an entry from the given payload and adds it to the request context.
WithTeam is a middleware that extracts the team from the given payload and adds it to the request context.
# Constants
DBKey is used to fetch the database connection from a context.
EntryKey is used to fetch the current entry from a context.
TeamKey is used to fetch the current team from a context.
UserKey is used to fetch the current user from a context.
UserStoreKey is used to fetch a the user storage.
# Variables
ErrAuthenticationRequired is returned from Authenticated middleware if the session can not be matched to an existing user.
ErrDeleteForbidden will be returned when a user tries to delete other users annotations.
ErrEmailExists is returned when a user wants to change his email to an already taken email address.
ErrEntryUnknown is returned if the entry_id cannot be matched to the requested entry_id.
ErrInvalidAccessKey is returned from a join request handler when the given access key does not match the teams access key.
ErrInvalidLogin is returned if the login request fails, either because the username or password is wrong.
ErrInvalidRoleParameter is returned from the set_role handler when the role is unknown.
ErrMissingAnchor will be returned when the Dash frontend fails to include an anchor for a new entry.
ErrMissingBody will be returned when you try to create an annotation without body.
ErrMissingEntryID is returned if the entry_id parameter is empty or not present.
ErrMissingPassword is returned for registration is missing the password parameter.
ErrMissingRoleParameter is returned from a set_role handler when no role parameter is present.
ErrMissingTeamName is returned when a team should be created and the name parameter is missing.
ErrMissingTitle will be returned when you try to create an annotation without a title.
ErrMissingUsername is returned for registration if missing the username parameter.
ErrMissingUsernameParameter is returned when a target username parameter is required, but missing.
ErrNotModerator will be returned when a user tries to remove an annotation from the public without being moderator.
ErrNotTeamModerator will be returned when a user tries to remove an annotation from a team without being team moderator.
ErrNotTeamOwner is returned when an action requires you to be the team owner, but you are not.
ErrPublicAnnotationForbidden will be returned when the requested identifier is banned from public.
ErrTeamNameExists is returned when a team should be created, and the name is already taken.
ErrTeamUnknown is returned when a name cannot be matched to the requested team name.
ErrUnknownUser is returned when an action requires a target user, but the given username is unknown.
ErrUpdateForbidden will be returned when a user tries to modify annotations he did not create.
ErrUsernameExists is returned for registration attempts where the username is taken.
# Structs
ContextAdapter is a compatability layer for http handlers which take a context as first arguments and return an error, to regular golang http handlers.
# Interfaces
ContextHandler allows http Handlers to includea context.
UserCreater stores a new user in the storage.
UserEmailUpdater updates a user with a new email.
UserFinderByUsername retrieves a user by username from the storage.
UserPasswordUpdater updates a user with a new plaintext password.
UserTokenUpdater takes a username and a token and updates the storage.
# Type aliases
ContextHandlerFunc defines a function that implements the ContextHandler interface.