Files
sonr/internal/gateway/routes.go
T

28 lines
906 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"
"github.com/onsonr/sonr/internal/gateway/context"
"github.com/onsonr/sonr/internal/gateway/handlers/index"
"github.com/onsonr/sonr/internal/gateway/handlers/register"
2024-12-05 20:36:58 -05:00
"github.com/onsonr/sonr/pkg/common/response"
config "github.com/onsonr/sonr/pkg/config/hway"
"gorm.io/gorm"
)
func RegisterRoutes(e *echo.Echo, env config.Hway, db *gorm.DB) error {
// Custom error handler for gateway
2024-12-05 20:36:58 -05:00
e.HTTPErrorHandler = response.RedirectOnError("http://localhost:3000")
2024-12-06 21:31:20 -05:00
// Inject session middleware with database connection
e.Use(context.Middleware(db, env))
2024-12-06 21:31:20 -05:00
2024-12-05 20:36:58 -05:00
// Register routes
e.GET("/", index.Handler)
e.GET("/register", register.HandleCreateProfile)
e.POST("/register/start", register.HandlePasskeyStart)
e.POST("/register/finish", register.HandlePasskeyFinish)
2024-12-06 21:31:20 -05:00
return nil
}