From 1b69a89c59263d8647e652cb08fe0de13770a508 Mon Sep 17 00:00:00 2001 From: Anish-Parkhi Date: Wed, 24 Apr 2024 19:16:11 +0530 Subject: [PATCH 1/3] fix: removed unnecessary strict post number checking causing error --- routes.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes.go b/routes.go index 2e4e8c2..f3b454a 100644 --- a/routes.go +++ b/routes.go @@ -159,7 +159,7 @@ func InitRoutes(apper Apper, r *mux.Router) *mux.Router { // Handle posts write.HandleFunc("/api/posts", handler.All(newPost)).Methods("POST") posts := write.PathPrefix("/api/posts/").Subrouter() - posts.HandleFunc("/{post:[a-zA-Z0-9]{10}}", handler.AllReader(fetchPost)).Methods("GET") + posts.HandleFunc("/{post:[a-zA-Z0-9]}", handler.AllReader(fetchPost)).Methods("GET") posts.HandleFunc("/{post:[a-zA-Z0-9]{10}}", handler.All(existingPost)).Methods("POST", "PUT") posts.HandleFunc("/{post:[a-zA-Z0-9]{10}}", handler.All(deletePost)).Methods("DELETE") posts.HandleFunc("/{post:[a-zA-Z0-9]{10}}/{property}", handler.AllReader(fetchPostProperty)).Methods("GET") From 94f12dfc29856e47b42e05c479d0fb377d0d3204 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Tue, 22 Oct 2024 14:01:40 -0400 Subject: [PATCH 2/3] Fix bad regex on /api/posts/{post} endpoint --- routes.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes.go b/routes.go index f3b454a..3abe88c 100644 --- a/routes.go +++ b/routes.go @@ -159,7 +159,7 @@ func InitRoutes(apper Apper, r *mux.Router) *mux.Router { // Handle posts write.HandleFunc("/api/posts", handler.All(newPost)).Methods("POST") posts := write.PathPrefix("/api/posts/").Subrouter() - posts.HandleFunc("/{post:[a-zA-Z0-9]}", handler.AllReader(fetchPost)).Methods("GET") + posts.HandleFunc("/{post:[a-zA-Z0-9]+}", handler.AllReader(fetchPost)).Methods("GET") posts.HandleFunc("/{post:[a-zA-Z0-9]{10}}", handler.All(existingPost)).Methods("POST", "PUT") posts.HandleFunc("/{post:[a-zA-Z0-9]{10}}", handler.All(deletePost)).Methods("DELETE") posts.HandleFunc("/{post:[a-zA-Z0-9]{10}}/{property}", handler.AllReader(fetchPostProperty)).Methods("GET") From 6e01bb7d94b6c5874690844f3f30aa0621d68d02 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Tue, 22 Oct 2024 14:04:05 -0400 Subject: [PATCH 3/3] Remove length restriction on other methods on /api/posts/{post} --- routes.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/routes.go b/routes.go index 3abe88c..efa79ea 100644 --- a/routes.go +++ b/routes.go @@ -160,9 +160,9 @@ func InitRoutes(apper Apper, r *mux.Router) *mux.Router { write.HandleFunc("/api/posts", handler.All(newPost)).Methods("POST") posts := write.PathPrefix("/api/posts/").Subrouter() posts.HandleFunc("/{post:[a-zA-Z0-9]+}", handler.AllReader(fetchPost)).Methods("GET") - posts.HandleFunc("/{post:[a-zA-Z0-9]{10}}", handler.All(existingPost)).Methods("POST", "PUT") - posts.HandleFunc("/{post:[a-zA-Z0-9]{10}}", handler.All(deletePost)).Methods("DELETE") - posts.HandleFunc("/{post:[a-zA-Z0-9]{10}}/{property}", handler.AllReader(fetchPostProperty)).Methods("GET") + posts.HandleFunc("/{post:[a-zA-Z0-9]+}", handler.All(existingPost)).Methods("POST", "PUT") + posts.HandleFunc("/{post:[a-zA-Z0-9]+}", handler.All(deletePost)).Methods("DELETE") + posts.HandleFunc("/{post:[a-zA-Z0-9]+}/{property}", handler.AllReader(fetchPostProperty)).Methods("GET") posts.HandleFunc("/claim", handler.All(addPost)).Methods("POST") posts.HandleFunc("/disperse", handler.All(dispersePost)).Methods("POST")