forked from jason/cpolis
Shorten lines by referencing frontend as f and backend as b
This commit is contained in:
@@ -6,10 +6,10 @@ import (
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"streifling.com/jason/cpolis/cmd/backend"
|
||||
b "streifling.com/jason/cpolis/cmd/backend"
|
||||
)
|
||||
|
||||
func saveSession(w http.ResponseWriter, r *http.Request, s *backend.CookieStore, u *backend.User) error {
|
||||
func saveSession(w http.ResponseWriter, r *http.Request, s *b.CookieStore, u *b.User) error {
|
||||
session, err := s.Get(r, "cookie")
|
||||
if err != nil {
|
||||
return fmt.Errorf("error getting session: %v", err)
|
||||
@@ -26,7 +26,7 @@ func saveSession(w http.ResponseWriter, r *http.Request, s *backend.CookieStore,
|
||||
return nil
|
||||
}
|
||||
|
||||
func HomePage(c *backend.Config, db *backend.DB, s *backend.CookieStore) http.HandlerFunc {
|
||||
func HomePage(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
numRows, err := db.CountEntries("users")
|
||||
if err != nil {
|
||||
@@ -53,7 +53,7 @@ func HomePage(c *backend.Config, db *backend.DB, s *backend.CookieStore) http.Ha
|
||||
}
|
||||
}
|
||||
|
||||
func Login(c *backend.Config, db *backend.DB, s *backend.CookieStore) http.HandlerFunc {
|
||||
func Login(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
userName := r.PostFormValue("username")
|
||||
password := r.PostFormValue("password")
|
||||
@@ -88,7 +88,7 @@ func Login(c *backend.Config, db *backend.DB, s *backend.CookieStore) http.Handl
|
||||
}
|
||||
}
|
||||
|
||||
func Logout(c *backend.Config, s *backend.CookieStore) http.HandlerFunc {
|
||||
func Logout(c *b.Config, s *b.CookieStore) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
session, err := s.Get(r, "cookie")
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user