Documentation ¶
Index ¶
- Constants
- Variables
- func Edit(args []string)
- func Patch(args []string)
- func Patch001(a *SQLAccessor) error
- func Patch002(a *SQLAccessor) error
- func Patch003(a *SQLAccessor) error
- func Patch004(a *SQLAccessor) error
- func Patch005(a *SQLAccessor) error
- func Run(args []string)
- func SendConfirmationEmail(email, code string) error
- func WriteAPIError(err error, status int, w http.ResponseWriter)
- type Accessor
- type Cache
- type CacheValue
- type Calendar
- func (c *Calendar) ActivateEvent(eventID string) error
- func (c *Calendar) CancelEvent(eventID string) error
- func (c *Calendar) CreateEvent(newEvent CalendarEvent) error
- func (c *Calendar) GetEvent(eventID string) (CalendarEvent, error)
- func (c *Calendar) InviteToEvent(eventID, email, name string) error
- func (c *Calendar) ListEvents(numEvents int) ([]CalendarEvent, error)
- func (c *Calendar) ListEventsBetween(start, end time.Time, numEvents int) ([]CalendarEvent, error)
- type CalendarConfig
- type CalendarEvent
- type CalendarSource
- type Config
- type CounterMetric
- type Friday
- type Friend
- type GaugeMetric
- type GoogleCalendar
- func (c *GoogleCalendar) ActivateEvent(eventID string) error
- func (c *GoogleCalendar) CancelEvent(eventID string) error
- func (c *GoogleCalendar) CreateEvent(newEvent CalendarEvent) error
- func (c *GoogleCalendar) GetEvent(eventID string) (CalendarEvent, error)
- func (c *GoogleCalendar) InviteToEvent(eventID, email, name string) error
- func (c *GoogleCalendar) ListEvents(numEvents int) ([]CalendarEvent, error)
- func (c *GoogleCalendar) ListEventsBetween(start, end time.Time, numEvents int) ([]CalendarEvent, error)
- type Group
- type IndexFridayData
- type Keycloak
- type MetricsRegistry
- type OAuth2Config
- type PageData
- type PixelPizza
- func (p *PixelPizza) AddCheese(c types.Cheese)
- func (p *PixelPizza) AddTopping(t types.Topping)
- func (p *PixelPizza) HTML(background string) string
- func (p *PixelPizza) ID() string
- func (p *PixelPizza) Image()
- func (p *PixelPizza) Render(background string) [][]string
- func (p *PixelPizza) SetCrust(doneness types.Doneness)
- func (p *PixelPizza) SetSauce(s types.Sauce)
- func (p *PixelPizza) String() string
- type PixelPizzaPageData
- type Preference
- type Preferences
- type ProfilePageData
- type PrometheusCounterMetric
- type PrometheusGaugeMetric
- type PrometheusRegistry
- type SQLAccessor
- func (a *SQLAccessor) AddFriday(date time.Time) error
- func (a *SQLAccessor) AddFriend(email, name string) error
- func (a *SQLAccessor) AddFriendToFriday(email string, friday Friday) error
- func (a *SQLAccessor) Close()
- func (a *SQLAccessor) CreateTables() error
- func (a *SQLAccessor) DoesFridayExist(date time.Time) (bool, error)
- func (a *SQLAccessor) GetFriday(date time.Time) (Friday, error)
- func (a *SQLAccessor) GetFriendName(email string) (string, error)
- func (a *SQLAccessor) GetPreferences(email string) (Preferences, error)
- func (a *SQLAccessor) GetUpcomingFridays(daysAhead int) ([]Friday, error)
- func (a *SQLAccessor) GetUpcomingFridaysAfter(after time.Time, daysAhead int) ([]Friday, error)
- func (a *SQLAccessor) IsFriendAllowed(email string) (bool, error)
- func (a *SQLAccessor) ListFridays() ([]Friday, error)
- func (a *SQLAccessor) ListFriends() ([]Friend, error)
- func (a *SQLAccessor) PatchTables() error
- func (a *SQLAccessor) RemoveFriday(date time.Time) error
- func (a *SQLAccessor) RemoveFriend(email string) error
- func (a *SQLAccessor) SetPreferences(email string, prefs Preferences) error
- func (a *SQLAccessor) UpdateFriday(friday Friday) error
- type Server
- func (s *Server) CheckAuthorization(r *http.Request) (*jwt.Token, *TokenClaims, bool)
- func (s *Server) CreateAndInvite(ID string, friday Friday, email, name string) error
- func (s *Server) GetWrapped(year int) (WrappedData, error)
- func (s *Server) Handle4xx(w http.ResponseWriter, r *http.Request)
- func (s *Server) Handle500(w http.ResponseWriter, r *http.Request)
- func (s *Server) HandleAPIAuth(w http.ResponseWriter, r *http.Request)
- func (s *Server) HandleAPIFriday(w http.ResponseWriter, r *http.Request)
- func (s *Server) HandleAPIGetFriday(token *jwt.Token, claims *TokenClaims, w http.ResponseWriter, r *http.Request)
- func (s *Server) HandleAPIPatchFriday(token *jwt.Token, claims *TokenClaims, w http.ResponseWriter, r *http.Request)
- func (s *Server) HandleAdmin(w http.ResponseWriter, r *http.Request)
- func (s *Server) HandleAdminEdit(w http.ResponseWriter, r *http.Request)
- func (s *Server) HandleGetProfile(w http.ResponseWriter, r *http.Request)
- func (s *Server) HandleIndex(w http.ResponseWriter, r *http.Request)
- func (s *Server) HandleLogin(w http.ResponseWriter, r *http.Request)
- func (s *Server) HandleLoginCallback(w http.ResponseWriter, r *http.Request)
- func (s *Server) HandleLogout(w http.ResponseWriter, r *http.Request)
- func (s *Server) HandlePizza(w http.ResponseWriter, r *http.Request)
- func (s *Server) HandleRSVP(w http.ResponseWriter, r *http.Request)
- func (s *Server) HandleUpdateProfile(w http.ResponseWriter, r *http.Request)
- func (s *Server) HandledWrapped(w http.ResponseWriter, r *http.Request)
- func (s *Server) Start() error
- func (s *Server) Stop()
- func (s *Server) WatchCalendar(period time.Duration)
- type TokenClaims
- type User
- type WrappedData
- type WrappedPageData
Constants ¶
View Source
const ( DefaultGoogleCalendarTimeout = 5 * time.Second DefaultGoogleCalendarTimezone = "America/New_York" )
View Source
const ( GmailSMTPServer = "" GmailSMTPPort = 800 )
View Source
const (
UserCacheExpire = 1 * time.Minute
)
Variables ¶
View Source
var AllPatches []func(*SQLAccessor) error
View Source
var (
ErrEventNotFound = errors.New("event not found")
)
View Source
var ErrInvalidPizzaID = errors.New("invalid pizza ID")
View Source
var EventDuration = time.Hour * 4
View Source
var GMAIL_API_KEY string
Functions ¶
func Patch001 ¶ added in v0.8.1
func Patch001(a *SQLAccessor) error
func Patch002 ¶ added in v0.9.0
func Patch002(a *SQLAccessor) error
func Patch003 ¶ added in v0.9.0
func Patch003(a *SQLAccessor) error
func Patch004 ¶ added in v0.11.0
func Patch004(a *SQLAccessor) error
func Patch005 ¶ added in v0.12.0
func Patch005(a *SQLAccessor) error
func SendConfirmationEmail ¶
func WriteAPIError ¶ added in v0.9.2
func WriteAPIError(err error, status int, w http.ResponseWriter)
Types ¶
type Accessor ¶
type Accessor interface { CreateTables() error IsFriendAllowed(email string) (bool, error) GetFriendName(email string) (string, error) AddFriend(email, name string) error ListFriends() ([]Friend, error) RemoveFriend(email string) error GetUpcomingFridays(daysAhead int) ([]Friday, error) GetUpcomingFridaysAfter(after time.Time, daysAhead int) ([]Friday, error) DoesFridayExist(date time.Time) (bool, error) ListFridays() ([]Friday, error) AddFriday(date time.Time) error GetFriday(date time.Time) (Friday, error) RemoveFriday(date time.Time) error UpdateFriday(friday Friday) error AddFriendToFriday(email string, friday Friday) error GetPreferences(email string) (Preferences, error) SetPreferences(email string, preferences Preferences) error }
type Cache ¶
type Cache[T any] struct { // contains filtered or unexported fields }
type CacheValue ¶
type CacheValue[V any] struct { // contains filtered or unexported fields }
type Calendar ¶
type Calendar struct {
// contains filtered or unexported fields
}
func NewCalendar ¶
func NewCalendar(source CalendarSource) *Calendar
func (*Calendar) ActivateEvent ¶
func (*Calendar) CancelEvent ¶
func (*Calendar) CreateEvent ¶
func (c *Calendar) CreateEvent(newEvent CalendarEvent) error
func (*Calendar) InviteToEvent ¶
func (*Calendar) ListEvents ¶
func (c *Calendar) ListEvents(numEvents int) ([]CalendarEvent, error)
func (*Calendar) ListEventsBetween ¶
type CalendarConfig ¶
type CalendarEvent ¶
type CalendarSource ¶
type CalendarSource interface { CreateEvent(CalendarEvent) error GetEvent(eventID string) (CalendarEvent, error) InviteToEvent(eventID, email, name string) error ListEvents(numEvents int) ([]CalendarEvent, error) ListEventsBetween(start, end time.Time, numEvents int) ([]CalendarEvent, error) CancelEvent(eventID string) error ActivateEvent(eventID string) error }
type Config ¶
type Config struct { Port int `yaml:"port"` StaticDir string `yaml:"staticDir"` ReadTimeout time.Duration `yaml:"readTimeout"` WriteTimeout time.Duration `yaml:"writeTimeout"` ShutdownTimeout time.Duration `yaml:"shutdownTimeout"` Calendar CalendarConfig `yaml:"calendar"` MetricsPort int `yaml:"metricsPort"` DBFile string `yaml:"dbFile"` OAuth2 OAuth2Config }
func LoadConfig ¶
func LoadConfigEnv ¶
func LoadConfigEnv() Config
type CounterMetric ¶
type CounterMetric interface {
Increment()
}
type GaugeMetric ¶
type GaugeMetric interface {
Set(float64)
}
type GoogleCalendar ¶
type GoogleCalendar struct { Timezone string Timeout time.Duration // contains filtered or unexported fields }
func NewGoogleCalendar ¶
func NewGoogleCalendar(credentialFile, tokenFile, id string, ctx context.Context) (*GoogleCalendar, error)
func (*GoogleCalendar) ActivateEvent ¶
func (c *GoogleCalendar) ActivateEvent(eventID string) error
func (*GoogleCalendar) CancelEvent ¶
func (c *GoogleCalendar) CancelEvent(eventID string) error
func (*GoogleCalendar) CreateEvent ¶
func (c *GoogleCalendar) CreateEvent(newEvent CalendarEvent) error
func (*GoogleCalendar) GetEvent ¶
func (c *GoogleCalendar) GetEvent(eventID string) (CalendarEvent, error)
func (*GoogleCalendar) InviteToEvent ¶
func (c *GoogleCalendar) InviteToEvent(eventID, email, name string) error
func (*GoogleCalendar) ListEvents ¶
func (c *GoogleCalendar) ListEvents(numEvents int) ([]CalendarEvent, error)
func (*GoogleCalendar) ListEventsBetween ¶
func (c *GoogleCalendar) ListEventsBetween(start, end time.Time, numEvents int) ([]CalendarEvent, error)
type IndexFridayData ¶
type Keycloak ¶ added in v0.8.1
type Keycloak struct {
// contains filtered or unexported fields
}
func NewKeycloak ¶ added in v0.8.1
func NewKeycloak(config OAuth2Config) (*Keycloak, error)
func (*Keycloak) DecodeAccessToken ¶ added in v0.9.2
type MetricsRegistry ¶
type MetricsRegistry interface { NewCounterMetric(name string, labels map[string]string) CounterMetric NewGaugeMetric(name string, labels map[string]string) GaugeMetric }
type OAuth2Config ¶ added in v0.8.0
type PageData ¶
type PageData struct { FridayTimes []IndexFridayData Name string LoggedIn bool LogoutURL string IsAdmin bool PixelPizza PixelPizzaPageData }
type PixelPizza ¶ added in v0.13.0
type PixelPizza struct {
// contains filtered or unexported fields
}
func NewPixelPizza ¶ added in v0.13.0
func NewPixelPizza() *PixelPizza
func NewPixelPizzaFromID ¶ added in v0.13.0
func NewPixelPizzaFromID(ID string) (*PixelPizza, error)
func NewPixelPizzaFromPreferences ¶ added in v0.13.0
func NewPixelPizzaFromPreferences(prefs Preferences) *PixelPizza
func (*PixelPizza) AddCheese ¶ added in v0.13.0
func (p *PixelPizza) AddCheese(c types.Cheese)
func (*PixelPizza) AddTopping ¶ added in v0.13.0
func (p *PixelPizza) AddTopping(t types.Topping)
func (*PixelPizza) HTML ¶ added in v0.13.0
func (p *PixelPizza) HTML(background string) string
func (*PixelPizza) ID ¶ added in v0.13.0
func (p *PixelPizza) ID() string
func (*PixelPizza) Image ¶ added in v0.13.0
func (p *PixelPizza) Image()
func (*PixelPizza) Render ¶ added in v0.13.0
func (p *PixelPizza) Render(background string) [][]string
func (*PixelPizza) SetCrust ¶ added in v0.13.0
func (p *PixelPizza) SetCrust(doneness types.Doneness)
func (*PixelPizza) SetSauce ¶ added in v0.13.0
func (p *PixelPizza) SetSauce(s types.Sauce)
func (*PixelPizza) String ¶ added in v0.13.0
func (p *PixelPizza) String() string
type PixelPizzaPageData ¶ added in v0.13.0
type Preference ¶ added in v0.11.0
type Preferences ¶ added in v0.11.0
type ProfilePageData ¶ added in v0.11.0
type ProfilePageData struct { LoggedIn bool Name string Toppings []Preference Cheese []Preference Sauce []Preference Doneness []Preference PixelPizza PixelPizzaPageData }
type PrometheusCounterMetric ¶
type PrometheusCounterMetric struct {
// contains filtered or unexported fields
}
func (*PrometheusCounterMetric) Increment ¶
func (m *PrometheusCounterMetric) Increment()
type PrometheusGaugeMetric ¶
type PrometheusGaugeMetric struct {
// contains filtered or unexported fields
}
func (*PrometheusGaugeMetric) Set ¶
func (m *PrometheusGaugeMetric) Set(value float64)
type PrometheusRegistry ¶
type PrometheusRegistry struct {
// contains filtered or unexported fields
}
func NewPrometheusRegistry ¶
func NewPrometheusRegistry() *PrometheusRegistry
func (*PrometheusRegistry) NewCounterMetric ¶
func (reg *PrometheusRegistry) NewCounterMetric(name string, labels map[string]string) CounterMetric
func (*PrometheusRegistry) NewGaugeMetric ¶
func (reg *PrometheusRegistry) NewGaugeMetric(name string, labels map[string]string) GaugeMetric
func (*PrometheusRegistry) Serve ¶
func (reg *PrometheusRegistry) Serve(port int)
type SQLAccessor ¶
type SQLAccessor struct {
// contains filtered or unexported fields
}
func NewSQLAccessor ¶
func NewSQLAccessor(dbfile string, skipPatch bool) (*SQLAccessor, error)
func (*SQLAccessor) AddFriend ¶
func (a *SQLAccessor) AddFriend(email, name string) error
func (*SQLAccessor) AddFriendToFriday ¶ added in v0.12.0
func (a *SQLAccessor) AddFriendToFriday(email string, friday Friday) error
func (*SQLAccessor) Close ¶
func (a *SQLAccessor) Close()
func (*SQLAccessor) CreateTables ¶
func (a *SQLAccessor) CreateTables() error
func (*SQLAccessor) DoesFridayExist ¶ added in v0.8.1
func (a *SQLAccessor) DoesFridayExist(date time.Time) (bool, error)
func (*SQLAccessor) GetFriday ¶ added in v0.9.2
func (a *SQLAccessor) GetFriday(date time.Time) (Friday, error)
func (*SQLAccessor) GetFriendName ¶
func (a *SQLAccessor) GetFriendName(email string) (string, error)
func (*SQLAccessor) GetPreferences ¶ added in v0.11.0
func (a *SQLAccessor) GetPreferences(email string) (Preferences, error)
func (*SQLAccessor) GetUpcomingFridays ¶
func (a *SQLAccessor) GetUpcomingFridays(daysAhead int) ([]Friday, error)
func (*SQLAccessor) GetUpcomingFridaysAfter ¶
func (*SQLAccessor) IsFriendAllowed ¶
func (a *SQLAccessor) IsFriendAllowed(email string) (bool, error)
TODO delete
func (*SQLAccessor) ListFridays ¶ added in v0.7.3
func (a *SQLAccessor) ListFridays() ([]Friday, error)
func (*SQLAccessor) ListFriends ¶ added in v0.7.3
func (a *SQLAccessor) ListFriends() ([]Friend, error)
func (*SQLAccessor) PatchTables ¶ added in v0.9.0
func (a *SQLAccessor) PatchTables() error
func (*SQLAccessor) RemoveFriday ¶ added in v0.7.3
func (a *SQLAccessor) RemoveFriday(date time.Time) error
func (*SQLAccessor) RemoveFriend ¶ added in v0.7.3
func (a *SQLAccessor) RemoveFriend(email string) error
TODO delete
func (*SQLAccessor) SetPreferences ¶ added in v0.11.0
func (a *SQLAccessor) SetPreferences(email string, prefs Preferences) error
func (*SQLAccessor) UpdateFriday ¶ added in v0.9.0
func (a *SQLAccessor) UpdateFriday(friday Friday) error
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) CheckAuthorization ¶ added in v0.9.2
func (*Server) CreateAndInvite ¶ added in v0.9.2
func (*Server) GetWrapped ¶
func (s *Server) GetWrapped(year int) (WrappedData, error)
func (*Server) HandleAPIAuth ¶ added in v0.9.2
func (s *Server) HandleAPIAuth(w http.ResponseWriter, r *http.Request)
func (*Server) HandleAPIFriday ¶ added in v0.9.2
func (s *Server) HandleAPIFriday(w http.ResponseWriter, r *http.Request)
func (*Server) HandleAPIGetFriday ¶ added in v0.9.2
func (s *Server) HandleAPIGetFriday(token *jwt.Token, claims *TokenClaims, w http.ResponseWriter, r *http.Request)
func (*Server) HandleAPIPatchFriday ¶ added in v0.9.2
func (s *Server) HandleAPIPatchFriday(token *jwt.Token, claims *TokenClaims, w http.ResponseWriter, r *http.Request)
func (*Server) HandleAdmin ¶ added in v0.8.1
func (s *Server) HandleAdmin(w http.ResponseWriter, r *http.Request)
func (*Server) HandleAdminEdit ¶ added in v0.9.0
func (s *Server) HandleAdminEdit(w http.ResponseWriter, r *http.Request)
func (*Server) HandleGetProfile ¶ added in v0.11.0
func (s *Server) HandleGetProfile(w http.ResponseWriter, r *http.Request)
func (*Server) HandleIndex ¶
func (s *Server) HandleIndex(w http.ResponseWriter, r *http.Request)
func (*Server) HandleLogin ¶ added in v0.8.0
func (s *Server) HandleLogin(w http.ResponseWriter, r *http.Request)
func (*Server) HandleLoginCallback ¶ added in v0.8.0
func (s *Server) HandleLoginCallback(w http.ResponseWriter, r *http.Request)
func (*Server) HandleLogout ¶ added in v0.8.0
func (s *Server) HandleLogout(w http.ResponseWriter, r *http.Request)
func (*Server) HandlePizza ¶ added in v0.13.0
func (s *Server) HandlePizza(w http.ResponseWriter, r *http.Request)
func (*Server) HandleRSVP ¶ added in v0.9.0
func (s *Server) HandleRSVP(w http.ResponseWriter, r *http.Request)
func (*Server) HandleUpdateProfile ¶ added in v0.11.0
func (s *Server) HandleUpdateProfile(w http.ResponseWriter, r *http.Request)
func (*Server) HandledWrapped ¶
func (s *Server) HandledWrapped(w http.ResponseWriter, r *http.Request)
func (*Server) WatchCalendar ¶
type TokenClaims ¶ added in v0.8.0
type TokenClaims struct { Exp int64 `json:"exp"` Iat int64 `json:"iat"` AuthTime int64 `json:"auth_time"` Jti string `json:"jti"` Iss string `json:"iss"` Aud string `json:"aud"` Sub string `json:"sub"` Typ string `json:"typ"` Azp string `json:"azp"` SessionState string `json:"session_state"` At_hash string `json:"at_hash"` Acr string `json:"acr"` Sid string `json:"sid"` EmailVerified bool `json:"email_verified"` Name string `json:"name"` PreferredUsername string `json:"preferred_username"` GivenName string `json:"given_name"` FamilyName string `json:"family_name"` Email string `json:"email"` Groups []string `json:"groups"` Roles []string `json:"roles"` }
func (*TokenClaims) HasRole ¶ added in v0.8.1
func (c *TokenClaims) HasRole(role string) bool
func (*TokenClaims) InGroup ¶ added in v0.9.0
func (c *TokenClaims) InGroup(group string) bool
type WrappedData ¶
Click to show internal directories.
Click to hide internal directories.