From 4eccefa8d59e3b5159492cd3ec6354ace6f1827e Mon Sep 17 00:00:00 2001 From: Alexis Poyen <apoyen@mail.apoyen.fr> Date: Tue, 19 May 2020 15:24:52 +0200 Subject: [PATCH] Refactor : don't export handlers in model except API handler --- internal/models/area.go | 2 +- internal/models/capturer.go | 4 ++-- internal/models/desk.go | 2 +- internal/models/election.go | 2 +- internal/models/models.go | 10 +++++----- internal/models/section.go | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/internal/models/area.go b/internal/models/area.go index ed4a68c..31f0af9 100644 --- a/internal/models/area.go +++ b/internal/models/area.go @@ -9,7 +9,7 @@ import ( "forge.grandlyon.com/apoyen/elections/internal/auth" ) -func (d *DataHandler) HandleArea(w http.ResponseWriter, r *http.Request) { +func (d *DataHandler) handleArea(w http.ResponseWriter, r *http.Request) { id, _ := strconv.Atoi(strings.TrimPrefix(r.URL.Path, "/api/Area/")) switch method := r.Method; method { case "GET": diff --git a/internal/models/capturer.go b/internal/models/capturer.go index f16f327..115b42d 100644 --- a/internal/models/capturer.go +++ b/internal/models/capturer.go @@ -10,8 +10,8 @@ import ( "forge.grandlyon.com/apoyen/elections/internal/auth" ) -// HandleCapturer handle API calls on Capturer -func (d *DataHandler) HandleCapturer(w http.ResponseWriter, r *http.Request) { +// handleCapturer handle API calls on Capturer +func (d *DataHandler) handleCapturer(w http.ResponseWriter, r *http.Request) { id, _ := strconv.Atoi(strings.TrimPrefix(r.URL.Path, "/api/Capturer/")) switch method := r.Method; method { case "GET": diff --git a/internal/models/desk.go b/internal/models/desk.go index fb314d5..d510f26 100644 --- a/internal/models/desk.go +++ b/internal/models/desk.go @@ -9,7 +9,7 @@ import ( "forge.grandlyon.com/apoyen/elections/internal/auth" ) -func (d *DataHandler) HandleDesk(w http.ResponseWriter, r *http.Request) { +func (d *DataHandler) handleDesk(w http.ResponseWriter, r *http.Request) { id, _ := strconv.Atoi(strings.TrimPrefix(r.URL.Path, "/api/Desk/")) switch method := r.Method; method { case "GET": diff --git a/internal/models/election.go b/internal/models/election.go index 6e8ea3f..f53f6e7 100644 --- a/internal/models/election.go +++ b/internal/models/election.go @@ -9,7 +9,7 @@ import ( "forge.grandlyon.com/apoyen/elections/internal/auth" ) -func (d *DataHandler) HandleElection(w http.ResponseWriter, r *http.Request) { +func (d *DataHandler) handleElection(w http.ResponseWriter, r *http.Request) { id, _ := strconv.Atoi(strings.TrimPrefix(r.URL.Path, "/api/Election/")) switch method := r.Method; method { case "GET": diff --git a/internal/models/models.go b/internal/models/models.go index 9fea419..40fc52b 100644 --- a/internal/models/models.go +++ b/internal/models/models.go @@ -217,15 +217,15 @@ func (d *DataHandler) ProcessAPI(w http.ResponseWriter, r *http.Request) { api := strings.Split(strings.TrimPrefix(r.URL.Path, "/api/"), "/")[0] switch api { case "Capturer": - d.HandleCapturer(w, r) + d.handleCapturer(w, r) case "Election": - d.HandleElection(w, r) + d.handleElection(w, r) case "Area": - d.HandleArea(w, r) + d.handleArea(w, r) case "Section": - d.HandleSection(w, r) + d.handleSection(w, r) case "Desk": - d.HandleDesk(w, r) + d.handleDesk(w, r) } } diff --git a/internal/models/section.go b/internal/models/section.go index fb6356d..dd81f8d 100644 --- a/internal/models/section.go +++ b/internal/models/section.go @@ -9,7 +9,7 @@ import ( "forge.grandlyon.com/apoyen/elections/internal/auth" ) -func (d *DataHandler) HandleSection(w http.ResponseWriter, r *http.Request) { +func (d *DataHandler) handleSection(w http.ResponseWriter, r *http.Request) { id, _ := strconv.Atoi(strings.TrimPrefix(r.URL.Path, "/api/Section/")) switch method := r.Method; method { case "GET": -- GitLab