Refactoring cont.
This commit is contained in:
@@ -5,14 +5,14 @@ import (
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
helpers "synlotto-website/helpers"
|
||||
httpHelpers "synlotto-website/helpers/http"
|
||||
templateHelpers "synlotto-website/helpers/template"
|
||||
|
||||
"synlotto-website/models"
|
||||
)
|
||||
|
||||
func NewDrawHandler(db *sql.DB) http.HandlerFunc {
|
||||
return helpers.AuthMiddleware(func(w http.ResponseWriter, r *http.Request) {
|
||||
return httpHelpers.AuthMiddleware(func(w http.ResponseWriter, r *http.Request) {
|
||||
context := templateHelpers.TemplateContext(w, r, models.TemplateData{})
|
||||
|
||||
if r.Method == http.MethodPost {
|
||||
@@ -39,7 +39,7 @@ func NewDrawHandler(db *sql.DB) http.HandlerFunc {
|
||||
}
|
||||
|
||||
func ModifyDrawHandler(db *sql.DB) http.HandlerFunc {
|
||||
return helpers.AuthMiddleware(func(w http.ResponseWriter, r *http.Request) {
|
||||
return httpHelpers.AuthMiddleware(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method == http.MethodPost {
|
||||
id := r.FormValue("id")
|
||||
_, err := db.Exec(`UPDATE results_thunderball SET game_type=?, draw_date=?, ball_set=?, machine=? WHERE id=?`,
|
||||
@@ -58,7 +58,7 @@ func ModifyDrawHandler(db *sql.DB) http.HandlerFunc {
|
||||
}
|
||||
|
||||
func DeleteDrawHandler(db *sql.DB) http.HandlerFunc {
|
||||
return helpers.AuthMiddleware(func(w http.ResponseWriter, r *http.Request) {
|
||||
return httpHelpers.AuthMiddleware(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method == http.MethodPost {
|
||||
id := r.FormValue("id")
|
||||
_, err := db.Exec(`DELETE FROM results_thunderball WHERE id = ?`, id)
|
||||
@@ -73,7 +73,7 @@ func DeleteDrawHandler(db *sql.DB) http.HandlerFunc {
|
||||
}
|
||||
|
||||
func ListDrawsHandler(db *sql.DB) http.HandlerFunc {
|
||||
return helpers.AuthMiddleware(func(w http.ResponseWriter, r *http.Request) {
|
||||
return httpHelpers.AuthMiddleware(func(w http.ResponseWriter, r *http.Request) {
|
||||
context := templateHelpers.TemplateContext(w, r, models.TemplateData{})
|
||||
draws := []models.DrawSummary{}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user