2025-01-04 18:51:40 -05:00
|
|
|
// Package gateway provides the default routes for the Sonr hway.
|
2025-01-04 19:52:54 -05:00
|
|
|
package app
|
2025-01-04 18:51:40 -05:00
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/labstack/echo-contrib/echoprometheus"
|
|
|
|
"github.com/labstack/echo/v4"
|
|
|
|
echomiddleware "github.com/labstack/echo/v4/middleware"
|
2025-01-06 14:44:28 -05:00
|
|
|
"github.com/onsonr/hway/app/common"
|
2025-01-04 21:13:51 -05:00
|
|
|
config "github.com/onsonr/hway/config"
|
2025-01-06 14:44:28 -05:00
|
|
|
hwayorm "github.com/onsonr/hway/models"
|
2025-01-05 01:48:14 -05:00
|
|
|
// "github.com/onsonr/hway/pkg/context"
|
2025-01-04 18:51:40 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
type Gateway = *echo.Echo
|
|
|
|
|
|
|
|
// New returns a new Gateway instance
|
|
|
|
func New(env config.Hway, ipc common.IPFS, dbq *hwayorm.Queries) (Gateway, error) {
|
|
|
|
e := echo.New()
|
|
|
|
|
|
|
|
// Built-in middleware
|
|
|
|
e.Use(echomiddleware.Logger())
|
|
|
|
e.Use(echomiddleware.Recover())
|
|
|
|
e.IPExtractor = echo.ExtractIPDirect()
|
|
|
|
e.Use(echoprometheus.NewMiddleware("hway"))
|
2025-01-04 21:13:51 -05:00
|
|
|
// e.Use(context.UseGateway(env, ipc, dbq))
|
2025-01-04 18:51:40 -05:00
|
|
|
|
|
|
|
// Register View Handlers
|
2025-01-04 21:13:51 -05:00
|
|
|
// e.HTTPErrorHandler = handlers.ErrorHandler
|
|
|
|
// e.GET("/", handlers.IndexHandler)
|
|
|
|
// handlers.RegisterHandler(e.Group("/register"))
|
2025-01-04 18:51:40 -05:00
|
|
|
return e, nil
|
|
|
|
}
|