Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrorReporter ¶
type ErrorReporter func(interfaces ...interface{})
type Handler ¶
type Handler struct {
// A Mux handles all routing and middleware.
*chi.Mux
// A UserService is the interface with the database for users
UserService models.UserService
// An ApplicationService is the interface with the database for applications
ApplicationService models.ApplicationService
// An RSVPService is the interface with the databsae for RSVPs
RSVPService models.RSVPService
// An AnnouncementService is the interface with the database for announcements
AnnouncementService models.AnnouncementService
// A RaffleService is the interface with the databse for raffles
RaffleService models.RaffleService
// A Mailer is used to send emails
Mailer mail.Mailer
// An S3 handles uploading files to S3
S3 s3.S3
// HTML templates to render
Templates *template.Template
// An ErrorReport reports errors to something like rollbar
ErrReporter ErrorReporter
// Stores session cookies
SessionStore *sessions.CookieStore
// Name cookie that stores sessions
SessionCookieName string
// Holds the current application status
Status status.Status
}
A Handler will route requests to their appropriate HandlerFunc.
func NewHandler ¶
func NewHandler(us models.UserService, as models.ApplicationService, rs models.RSVPService, anns models.AnnouncementService, ras models.RaffleService, mailer mail.Mailer, S3 s3.S3) *Handler
NewHandler creates a handler for web requests.
func (*Handler) Error ¶
func (h *Handler) Error(w http.ResponseWriter, r *http.Request, err error, redirectPath string, interfaces ...interface{})
Error checks an error given to it. If it's a known error that we've made we can show it to the user as a flash. If it's unknown then we should tell the user that something went wrong and report the error to rollbar.
type Page ¶
type Page struct {
Title string
// Current status of app
Status status.Status
// A generic place to put unstructured data
Data interface{}
// An array of messages to show the user
Flashes []flash.Flash
// Values to be put back into a form when shown to a user again
// For example, when they log in with the wrong password we want
// the email they tried to log in with to persist
FormRefill interface{}
// The user's email, blank if user not logged in
Email string
IsAuthenticated bool
}
A Page is all the data needed to render a page.
Click to show internal directories.
Click to hide internal directories.