Documentation ¶
Index ¶
- Constants
- Variables
- func BuildRoutes() http.Handler
- func CsrfMiddleware(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
- func GameHandler(w http.ResponseWriter, r *http.Request)
- func GetSession(r *http.Request) *sessions.Session
- func HomeHandler(w http.ResponseWriter, r *http.Request)
- func IsLoggedIn(r *http.Request) bool
- func Login(u *User, w http.ResponseWriter, r *http.Request)
- func LoginRequiredMiddleware(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
- func LoginSuccessHandler(w http.ResponseWriter, r *http.Request)
- func Logout(w http.ResponseWriter, r *http.Request)
- func LogoutHandler(w http.ResponseWriter, r *http.Request)
- func ProfileHandler(w http.ResponseWriter, r *http.Request)
- func SendMail(to []string, subject, message string) error
- func SetContextUser(user *User, r *http.Request)
- func UserMiddleware(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
- func VerifyHandler(w http.ResponseWriter, r *http.Request)
- type Card
- type Deck
- type Hand
- type User
Constants ¶
Variables ¶
var ( SUITS []string = []string{"club", "diamond", "heart", "spade"} RANKS []string = []string{"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "j", "q", "k"} DEFAULT_HAND_SIZE = 9 // GLYPH map[string]string = map[string]string{ "s1": "\U0001f0a1", "h1": "\U0001f0b1", "d1": "\U0001f0c1", "c1": "\U0001f0d1", "s2": "\U0001f0a2", "h2": "\U0001f0b2", "d2": "\U0001f0c2", "c2": "\U0001f0d2", "s3": "\U0001f0a3", "h3": "\U0001f0b3", "d3": "\U0001f0c3", "c3": "\U0001f0d3", "s4": "\U0001f0a4", "h4": "\U0001f0b4", "d4": "\U0001f0c4", "c4": "\U0001f0d4", "s5": "\U0001f0a5", "h5": "\U0001f0b5", "d5": "\U0001f0c5", "c5": "\U0001f0d5", "s6": "\U0001f0a6", "h6": "\U0001f0b6", "d6": "\U0001f0c6", "c6": "\U0001f0d6", "s7": "\U0001f0a7", "h7": "\U0001f0b7", "d7": "\U0001f0c7", "c7": "\U0001f0d7", "s8": "\U0001f0a8", "h8": "\U0001f0b8", "d8": "\U0001f0c8", "c8": "\U0001f0d8", "s9": "\U0001f0a9", "h9": "\U0001f0b9", "d9": "\U0001f0c9", "c9": "\U0001f0d9", "s10": "\U0001f0aa", "h10": "\U0001f0ba", "d10": "\U0001f0ca", "c10": "\U0001f0da", "sj": "\U0001f0ab", "hj": "\U0001f0bb", "dj": "\U0001f0cb", "cj": "\U0001f0db", "sq": "\U0001f0ad", "hq": "\U0001f0bd", "dq": "\U0001f0cd", "cq": "\U0001f0dd", "sk": "\U0001f0ae", "hk": "\U0001f0be", "dk": "\U0001f0ce", "ck": "\U0001f0de", } )
Functions ¶
func BuildRoutes ¶
BuildRoutes returns the routes for the application.
func CsrfMiddleware ¶
func CsrfMiddleware(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
CsrfMiddleware adds CSRF support via nosurf.
func GameHandler ¶
func GameHandler(w http.ResponseWriter, r *http.Request)
func GetSession ¶
GetSession returns the session for the site.
func HomeHandler ¶
func HomeHandler(w http.ResponseWriter, r *http.Request)
func IsLoggedIn ¶
IsLoggedIn is a convenience function for checking if a User exists in the request context.
func Login ¶
func Login(u *User, w http.ResponseWriter, r *http.Request)
Login adds the User's id to the session.
func LoginRequiredMiddleware ¶
func LoginRequiredMiddleware(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
LoginRequiredMiddleware ensures a User is logged in, otherwise redirects them to the login page.
func LoginSuccessHandler ¶
func LoginSuccessHandler(w http.ResponseWriter, r *http.Request)
func Logout ¶
func Logout(w http.ResponseWriter, r *http.Request)
Logout removes the User from their session.
func LogoutHandler ¶
func LogoutHandler(w http.ResponseWriter, r *http.Request)
func ProfileHandler ¶
func ProfileHandler(w http.ResponseWriter, r *http.Request)
func SetContextUser ¶
SetContextUser stores the given user in the request context.
func UserMiddleware ¶
func UserMiddleware(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
UserMiddleware checks for the User in the session and adds them to the request context if they exist.
func VerifyHandler ¶
func VerifyHandler(w http.ResponseWriter, r *http.Request)
Types ¶
type User ¶
type User struct { Id int64 `db:"id"` Email string `db:"email"` Token string `db:"token"` Ttl time.Time `db:"ttl"` OriginUrl null.String `db:"originurl"` }
func GetContextUser ¶
GetContextUser returns the User for the given request context or nil.
func (*User) IsValidToken ¶
IsValidToken returns a bool indicating that the User's current token hasn't expired and that the provided token is valid.
func (*User) RefreshToken ¶
RefreshToken refreshes Ttl and Token for the User.