Files
sonr/pkg/gateway/routes.go
T

26 lines
858 B
Go
Raw Normal View History

2024-12-05 20:36:58 -05:00
// Package gateway provides the default routes for the Sonr hway.
package gateway
import (
"github.com/labstack/echo/v4"
2024-12-05 20:36:58 -05:00
"github.com/onsonr/sonr/pkg/common/response"
"github.com/onsonr/sonr/pkg/gateway/config"
"github.com/onsonr/sonr/pkg/gateway/handlers"
2024-12-05 20:36:58 -05:00
"github.com/onsonr/sonr/pkg/gateway/internal/database"
"github.com/onsonr/sonr/pkg/gateway/internal/session"
)
2024-12-05 20:36:58 -05:00
func RegisterRoutes(e *echo.Echo, env config.Env) {
// Custom error handler for gateway
2024-12-05 20:36:58 -05:00
e.HTTPErrorHandler = response.RedirectOnError("http://localhost:3000")
// Inject session middleware
e.Use(session.Middleware(env))
e.Use(database.Middleware(env))
// Register routes
e.GET("/", handlers.HandleIndex)
e.GET("/register", handlers.HandleRegisterView(env))
e.POST("/register/start", handlers.HandleRegisterStart)
e.POST("/register/finish", handlers.HandleRegisterFinish)
}