Support dynamic url based on Service settings
1 files changed, 13 insertions(+), 6 deletions(-)

M feedback.go
M feedback.go +13 -6
@@ 20,9 20,6 @@ import (
 
 var hostPattern = regexp.MustCompile(`^sns\.[a-zA-Z0-9\-]{3,}\.amazonaws\.com(\.cn)?$`)
 
-// FeedbackURL is the url to call the feedback handler
-var FeedbackURL string = "/ses-feedback"
-
 // Actions ...
 type Actions interface {
 	Bounce(data map[string]any) error

          
@@ 42,11 39,12 @@ type Service struct {
 	eg      *echo.Group
 	actions Actions
 	verify  bool
+	url     string
 }
 
 // RegisterRoutes ...
 func (s *Service) RegisterRoutes() {
-	s.eg.POST(FeedbackURL, s.Feedback).Name = s.RouteName("feedback")
+	s.eg.POST(s.url, s.Feedback).Name = s.RouteName("endpoint")
 }
 
 // RouteName ...

          
@@ 215,8 213,17 @@ func (s *Service) Feedback(c echo.Contex
 }
 
 // NewService ...
-func NewService(eg *echo.Group, ac Actions, verify bool) *Service {
-	service := &Service{name: "ses-feedback", eg: eg, actions: ac, verify: verify}
+func NewService(eg *echo.Group, ac Actions, verify bool, url string) *Service {
+	if url == "" {
+		url = "/ses-feedback"
+	}
+	service := &Service{
+		name:    "ses-feedback",
+		eg:      eg,
+		actions: ac,
+		verify:  verify,
+		url:     url,
+	}
 	service.RegisterRoutes()
 	return service
 }