Documentation ¶
Overview ¶
Package handlers contains the handler for all the HTTP request on the server.
Types and functions whose name ends with "Handler" are the handlers. Types whose name ends with "Query" are the types of the information received in the requests. Types whose name ends with "Answer" are the types of the information sent in the responses.
Handlers are either handler functions (of type server.HandleFunction), or factories for handler objects (of type server.Handler).
Index ¶
- func ConfigHandler(ctx context.Context, response server.Response, request *server.Request)
- func ConfirmHandler() confirmHandler
- func CountInfoHandler(ctx context.Context, response server.Response, request *server.Request)
- func CreateHandler(evtManager events.Manager) createHandler
- func DeleteHandler(evtManager events.Manager) deleteHandler
- func ForgotHandler(evtManager events.Manager) forgotHandler
- func LaunchHandler(evtManager events.Manager) launchHandler
- func ListHandler(ctx context.Context, response server.Response, request *server.Request)
- func LoginHandler(ctx context.Context, response server.Response, request *server.Request)
- func PasswdHandler(ctx context.Context, response server.Response, request *server.Request)
- func PollHandler(ctx context.Context, response server.Response, request *server.Request)
- func PollNotifHandler(notifChannel services.PollNotifChannel) *pollNotifHandler
- func RefreshHandler(ctx context.Context, response server.Response, request *server.Request)
- func ReverifyHandler(evtManager events.Manager) reverifyHandler
- func ShortURLHandler(ctx context.Context, response server.Response, request *server.Request)
- func SignupHandler(evtManager events.Manager) signupHandler
- func UninominalBallotHandler(ctx context.Context, response server.Response, request *server.Request)
- func UninominalVoteHandler(evtManager events.Manager) uninominalVoteHandler
- type BallotType
- type ConfigAnswer
- type ConfirmAnswer
- type CountInfoAnswer
- type CountInfoEntry
- type CreatePollElectorate
- type CreateQuery
- type InformationType
- type ListAnswer
- type NuDate
- type PollAction
- type PollAlternative
- type PollAnswer
- type PollInfo
- type PollNotifAnswerEntry
- type PollNotifQuery
- type ProfileInfo
- type SimpleAlternative
- type UninominalBallotAnswer
- type UninominalVoteQuery
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfigHandler ¶
ConfigHandler sends the "frontend" section of the configuration file.
func CountInfoHandler ¶
CountInfoEntry sends the plurality result of a previous round.
func CreateHandler ¶
CreateHandler creates a new poll.
func DeleteHandler ¶
DeleteHandler deletes a poll.
func ForgotHandler ¶ added in v0.1.5
ForgotHandler handles requests to change a user password when the user has forgotten the current password.
func LaunchHandler ¶ added in v0.1.6
LaunchHandler forces the start of a waiting poll.
func ListHandler ¶
ListHandler lists the available polls.
func LoginHandler ¶
LoginHandler starts a new session for an existing user.
func PasswdHandler ¶ added in v0.1.5
PasswdHandler changes the password of an existing user. The request must reference a valid confirmation of type passwd.
func PollHandler ¶
PollHandler provides general information about a poll.
func PollNotifHandler ¶
func PollNotifHandler(notifChannel services.PollNotifChannel) *pollNotifHandler
PollNotifHandler retrieves the current list of notifications for the user. The same notification may be listed in more than one consecutive answers.
func RefreshHandler ¶
RefreshHandler creates a fresh new session from an older active session.
func ReverifyHandler ¶
ReverifyHandler requests the email address of the current user to be verified.
func ShortURLHandler ¶ added in v0.1.7
ShortURLHandler handles shortcut URL of polls, redirecting to the virtual URL of the poll.
func SignupHandler ¶
SignupHandler creates a new user. On success, a new session is started.
func UninominalBallotHandler ¶
func UninominalBallotHandler(ctx context.Context, response server.Response, request *server.Request)
UninominalBallotAnswer sends the previous ballot (if any), the current one (if any) and all the alternatives.
func UninominalVoteHandler ¶
UninominalVoteHandler votes for an alternative. Blank votes are also permitted.
Types ¶
type BallotType ¶
type BallotType uint8
const ( BallotTypeClosed BallotType = iota BallotTypeUninominal )
type ConfigAnswer ¶
type ConfigAnswer struct {
DemoPollSegment string
}
type ConfirmAnswer ¶
type ConfirmAnswer struct {
Type db.ConfirmationType
}
type CountInfoAnswer ¶
type CountInfoAnswer struct {
Result []CountInfoEntry
}
type CountInfoEntry ¶
type CountInfoEntry struct { Alternative PollAlternative Count uint32 }
type CreatePollElectorate ¶ added in v0.1.7
type CreatePollElectorate int8
const ( CreatePollElectorateAll CreatePollElectorate = iota - 1 CreatePollElectorateLogged CreatePollElectorateVerified )
func (CreatePollElectorate) ToDB ¶ added in v0.1.7
func (self CreatePollElectorate) ToDB() db.Electorate
type CreateQuery ¶
type CreateQuery struct { Title string Description string Hidden bool Electorate CreatePollElectorate Start time.Time Alternatives []SimpleAlternative ReportVote bool MinNbRounds uint8 MaxNbRounds uint8 Deadline time.Time MaxRoundDuration uint64 // milliseconds RoundThreshold float64 ShortURL string }
type InformationType ¶
type InformationType uint8
const ( InformationTypeNoneYet InformationType = iota InformationTypeCounts )
type ListAnswer ¶
type ListAnswer struct { Public []listAnswerEntry Own []listAnswerEntry }
type NuDate ¶
NuDate is a marshalable version of sql.NullTime.
func (NuDate) MarshalJSON ¶
func (*NuDate) UnmarshalJSON ¶
type PollAction ¶
type PollAction uint8
const ( PollActionVote PollAction = iota PollActionModif PollActionPart PollActionTerm PollActionWait )
type PollAlternative ¶
type PollAnswer ¶
type PollAnswer struct { Title string Description string Admin string CreationTime time.Time CurrentRound uint8 Active bool State string CarryForward bool Start time.Time RoundDeadline time.Time PollDeadline time.Time MaxRoundDuration uint64 // in milliseconds MinNbRounds uint8 MaxNbRounds uint8 Ballot BallotType Information InformationType }
type PollInfo ¶
type PollInfo struct { Id uint32 NbChoices uint8 Active bool CurrentRound uint8 Public bool Logged bool Participate bool }
PollInfo holds information on a poll as returned by checkPollAccess.
func (PollInfo) BallotType ¶
func (pollInfo PollInfo) BallotType() BallotType
func (PollInfo) InformationType ¶
func (pollInfo PollInfo) InformationType() InformationType
type PollNotifAnswerEntry ¶
type PollNotifQuery ¶
type ProfileInfo ¶
type ProfileInfo struct {
Verified bool
}
type SimpleAlternative ¶
type UninominalBallotAnswer ¶
type UninominalBallotAnswer struct { Previous uninominalBallot Current uninominalBallot Alternatives []PollAlternative }
UninominalBallotAnswer represents the response sent by UninominalBallotHandler. The fields Previous and Current are not sent in the JSON representation if the user did not vote. If the user abstained, these fields are replaced with fields PreviousIsBlank or CurrentIsBlank with the boolean value true.
func (*UninominalBallotAnswer) MarshalJSON ¶
func (self *UninominalBallotAnswer) MarshalJSON() (ret []byte, err error)
MarshalJSON implements json.Marshaler.