From 5fbb9933f85d72b4b2e19cae134768b6fcdfb491 Mon Sep 17 00:00:00 2001 From: adrian-grassl <83593889+adrian-grassl@users.noreply.github.com> Date: Fri, 28 Jun 2024 10:29:08 +0200 Subject: [PATCH] Add routes to same group (APIRoute) (#75) --- components/poi/component.go | 3 ++- components/poi/routes.go | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/components/poi/component.go b/components/poi/component.go index 663128e..2dbbaac 100644 --- a/components/poi/component.go +++ b/components/poi/component.go @@ -76,7 +76,8 @@ func run() error { Component.LogInfo("Starting API server ...") - setupRoutes(e) + setupRoutes(e.Group(APIRoute)) + go func() { Component.LogInfof("You can now access the API using: http://%s", ParamsRestAPI.BindAddress) if err := e.Start(ParamsRestAPI.BindAddress); err != nil && !errors.Is(err, http.ErrServerClosed) { diff --git a/components/poi/routes.go b/components/poi/routes.go index 5d19275..1f2aa15 100644 --- a/components/poi/routes.go +++ b/components/poi/routes.go @@ -18,9 +18,9 @@ const ( RouteValidateProof = "/validate" ) -func setupRoutes(e *echo.Echo) { +func setupRoutes(routeGroup *echo.Group) { - e.GET(RouteCreateProof, func(c echo.Context) error { + routeGroup.GET(RouteCreateProof, func(c echo.Context) error { resp, err := createProof(c) if err != nil { return err @@ -29,7 +29,7 @@ func setupRoutes(e *echo.Echo) { return httpserver.JSONResponse(c, http.StatusOK, resp) }) - e.POST(RouteValidateProof, func(c echo.Context) error { + routeGroup.POST(RouteValidateProof, func(c echo.Context) error { resp, err := validateProof(c) if err != nil { return err