Initial draft of shifting from chi to gorilla/mux

This commit is contained in:
Eli Ribble 2026-04-01 16:19:11 +00:00
parent 5172400803
commit 6c311c76e3
No known key found for this signature in database
15 changed files with 993 additions and 141 deletions

View file

@ -1,66 +1,64 @@
package api
import (
"github.com/go-chi/chi/v5"
"github.com/go-chi/render"
"github.com/Gleipnir-Technology/nidus-sync/auth"
"github.com/Gleipnir-Technology/nidus-sync/platform/file"
"github.com/gorilla/mux"
)
func AddRoutes(r chi.Router) {
r.Use(render.SetContentType(render.ContentTypeJSON))
func AddRoutes(r *mux.Router) {
//r.Use(render.SetContentType(render.ContentTypeJSON))
// Unauthenticated endpoints
r.Post("/signin", handlerJSONPost(postSignin))
r.Post("/signup", handlerJSONPost(postSignup))
r.HandleFunc("/signin", handlerJSONPost(postSignin))
r.HandleFunc("/signup", handlerJSONPost(postSignup))
// Authenticated endpoints
r.Method("POST", "/audio/{uuid}", auth.NewEnsureAuth(apiAudioPost))
r.Method("POST", "/audio/{uuid}/content", auth.NewEnsureAuth(apiAudioContentPost))
r.Method("POST", "/avatar", authenticatedHandlerPostMultipart(avatarPost, file.CollectionAvatar))
r.Method("GET", "/client/ios", auth.NewEnsureAuth(handleClientIos))
r.Method("GET", "/communication", authenticatedHandlerJSON(listCommunication))
r.Method("POST", "/configuration/integration/arcgis", authenticatedHandlerJSONPost(postConfigurationIntegrationArcgis))
r.Method("GET", "/events", auth.NewEnsureAuth(streamEvents))
r.Method("POST", "/image/{uuid}", auth.NewEnsureAuth(apiImagePost))
r.Method("GET", "/image/{uuid}/content", auth.NewEnsureAuth(apiImageContentGet))
r.Method("POST", "/image/{uuid}/content", auth.NewEnsureAuth(apiImageContentPost))
r.Method("GET", "/leads", authenticatedHandlerJSON(listLead))
r.Method("POST", "/leads", authenticatedHandlerJSONPost(postLeads))
r.Method("GET", "/mosquito-source", auth.NewEnsureAuth(apiMosquitoSource))
r.Method("POST", "/publicreport/invalid", authenticatedHandlerJSONPost(postPublicreportInvalid))
r.Method("POST", "/publicreport/signal", authenticatedHandlerJSONPost(postPublicreportSignal))
r.Method("POST", "/publicreport/message", authenticatedHandlerJSONPost(postPublicreportMessage))
r.Method("POST", "/review/pool", authenticatedHandlerJSONPost(postReviewPool))
r.Method("GET", "/review-task", authenticatedHandlerJSON(listReviewTask))
r.Method("GET", "/service-request", auth.NewEnsureAuth(apiServiceRequest))
r.Method("GET", "/signal", authenticatedHandlerJSON(listSignal))
r.Method("POST", "/sudo/email", authenticatedHandlerJSONPost(postSudoEmail))
r.Method("POST", "/sudo/sms", authenticatedHandlerJSONPost(postSudoSMS))
r.Method("POST", "/sudo/sse", authenticatedHandlerJSONPost(postSudoSSE))
r.Method("GET", "/trap-data", auth.NewEnsureAuth(apiTrapData))
r.Method("GET", "/tile/{z}/{y}/{x}", auth.NewEnsureAuth(getTile))
r.Method("POST", "/upload/pool/flyover", authenticatedHandlerPostMultipart(postUploadPoolFlyoverCreate, file.CollectionCSV))
r.Method("POST", "/upload/pool/custom", authenticatedHandlerPostMultipart(postUploadPoolCustomCreate, file.CollectionCSV))
r.Method("GET", "/upload", authenticatedHandlerJSON(getUploadList))
r.Method("GET", "/upload/{id}", authenticatedHandlerJSON(getUploadByID))
r.Method("POST", "/upload/{id}/commit", authenticatedHandlerJSONPost(postUploadCommit))
r.Method("POST", "/upload/{id}/discard", authenticatedHandlerJSONPost(postUploadDiscard))
r.Method("GET", "/user/self", authenticatedHandlerJSON(getUserSelf))
r.Method("GET", "/user/suggestion", authenticatedHandlerJSON(listUserSuggestion))
r.Method("GET", "/user", authenticatedHandlerJSON(listUser))
r.Method("PUT", "/user/{id}", authenticatedHandlerJSONPut(userPut))
r.Handle("/audio/{uuid}", auth.NewEnsureAuth(apiAudioPost)).Methods("POST")
r.Handle("/audio/{uuid}/content", auth.NewEnsureAuth(apiAudioContentPost)).Methods("POST")
r.Handle("/avatar", authenticatedHandlerPostMultipart(avatarPost, file.CollectionAvatar)).Methods("POST")
r.Handle("/client/ios", auth.NewEnsureAuth(handleClientIos)).Methods("GET")
r.Handle("/communication", authenticatedHandlerJSON(listCommunication)).Methods("GET")
r.Handle("/configuration/integration/arcgis", authenticatedHandlerJSONPost(postConfigurationIntegrationArcgis)).Methods("POST")
r.Handle("/events", auth.NewEnsureAuth(streamEvents)).Methods("GET")
r.Handle("/image/{uuid}", auth.NewEnsureAuth(apiImagePost)).Methods("POST")
r.Handle("/image/{uuid}/content", auth.NewEnsureAuth(apiImageContentGet)).Methods("GET")
r.Handle("/image/{uuid}/content", auth.NewEnsureAuth(apiImageContentPost)).Methods("POST")
r.Handle("/leads", authenticatedHandlerJSON(listLead)).Methods("GET")
r.Handle("/leads", authenticatedHandlerJSONPost(postLeads)).Methods("POST")
r.Handle("/mosquito-source", auth.NewEnsureAuth(apiMosquitoSource)).Methods("GET")
r.Handle("/publicreport/invalid", authenticatedHandlerJSONPost(postPublicreportInvalid)).Methods("POST")
r.Handle("/publicreport/signal", authenticatedHandlerJSONPost(postPublicreportSignal)).Methods("POST")
r.Handle("/publicreport/message", authenticatedHandlerJSONPost(postPublicreportMessage)).Methods("POST")
r.Handle("/review/pool", authenticatedHandlerJSONPost(postReviewPool)).Methods("POST")
r.Handle("/review-task", authenticatedHandlerJSON(listReviewTask)).Methods("GET")
r.Handle("/service-request", auth.NewEnsureAuth(apiServiceRequest)).Methods("GET")
r.Handle("/signal", authenticatedHandlerJSON(listSignal)).Methods("GET")
r.Handle("/sudo/email", authenticatedHandlerJSONPost(postSudoEmail)).Methods("POST")
r.Handle("/sudo/sms", authenticatedHandlerJSONPost(postSudoSMS)).Methods("POST")
r.Handle("/sudo/sse", authenticatedHandlerJSONPost(postSudoSSE)).Methods("POST")
r.Handle("/trap-data", auth.NewEnsureAuth(apiTrapData)).Methods("GET")
r.Handle("/tile/{z}/{y}/{x}", auth.NewEnsureAuth(getTile)).Methods("GET")
r.Handle("/upload/pool/flyover", authenticatedHandlerPostMultipart(postUploadPoolFlyoverCreate, file.CollectionCSV)).Methods("POST")
r.Handle("/upload/pool/custom", authenticatedHandlerPostMultipart(postUploadPoolCustomCreate, file.CollectionCSV)).Methods("POST")
r.Handle("/upload", authenticatedHandlerJSON(getUploadList)).Methods("GET")
r.Handle("/upload/{id}", authenticatedHandlerJSON(getUploadByID)).Methods("GET")
r.Handle("/upload/{id}/commit", authenticatedHandlerJSONPost(postUploadCommit)).Methods("POST")
r.Handle("/upload/{id}/discard", authenticatedHandlerJSONPost(postUploadDiscard)).Methods("POST")
r.Handle("/user/self", authenticatedHandlerJSON(getUserSelf)).Methods("GET")
r.Handle("/user/suggestion", authenticatedHandlerJSON(listUserSuggestion)).Methods("GET")
r.Handle("/user", authenticatedHandlerJSON(listUser)).Methods("GET")
r.Handle("/user/{id}", authenticatedHandlerJSONPut(userPut)).Methods("PUT")
// Unauthenticated endpoints
r.Get("/district", apiGetDistrict)
r.Get("/district/{slug}/logo", apiGetDistrictLogo)
r.Get("/compliance-request/image/pool/{public_id}", getComplianceRequestImagePool)
r.Post("/twilio/call", twilioCallPost)
r.Post("/twilio/call/status", twilioCallStatusPost)
r.Post("/twilio/message", twilioMessagePost)
r.Post("/twilio/text", twilioTextPost)
r.Post("/twilio/text/status", twilioTextStatusPost)
r.Get("/voipms/text", voipmsTextGet)
r.Post("/voipms/text", voipmsTextPost)
r.Get("/webhook/fieldseeker", webhookFieldseeker)
r.Post("/webhook/fieldseeker", webhookFieldseeker)
r.HandleFunc("/district", apiGetDistrict).Methods("GET")
r.HandleFunc("/district/{slug}/logo", apiGetDistrictLogo).Methods("GET")
r.HandleFunc("/compliance-request/image/pool/{public_id}", getComplianceRequestImagePool).Methods("GET")
r.HandleFunc("/twilio/call", twilioCallPost).Methods("POST")
r.HandleFunc("/twilio/call/status", twilioCallStatusPost).Methods("POST")
r.HandleFunc("/twilio/message", twilioMessagePost).Methods("POST")
r.HandleFunc("/twilio/text", twilioTextPost).Methods("POST")
r.HandleFunc("/twilio/text/status", twilioTextStatusPost).Methods("POST")
r.HandleFunc("/voipms/text", voipmsTextGet).Methods("GET")
r.HandleFunc("/voipms/text", voipmsTextPost).Methods("POST")
r.HandleFunc("/webhook/fieldseeker", webhookFieldseeker).Methods("GET")
r.HandleFunc("/webhook/fieldseeker", webhookFieldseeker).Methods("POST")
}