Serie: Go
go
30 righe
· Aggiornato 2026-04-18
router.go
Go/payment-gateway-challenge/internal/router/router.go
// Package router configures Echo middlewares and REST routes.
package router
import (
"payment-gateway-challenge/internal/handlers"
"github.com/labstack/echo/v4"
echomw "github.com/labstack/echo/v4/middleware"
echoSwagger "github.com/swaggo/echo-swagger"
)
// NewEcho builds the HTTP server with routes registered on the official path
// prefix /api/payments (matching the reference Go template style).
func NewEcho(api *handlers.PaymentAPI) *echo.Echo {
e := echo.New()
e.HideBanner = true
e.Use(echomw.Recover())
e.Use(echomw.Logger())
e.GET("/ping", handlers.Ping)
// OpenAPI UI (generated by swag — run `make swagger` after changing annotations).
e.GET("/swagger/*", echoSwagger.WrapHandler)
e.POST("/api/payments", api.ProcessPayment)
e.GET("/api/payments/:id", api.GetPayment)
return e
}
Articoli correlati
Go
go
Aggiornato 2026-04-18
main.go
main.go — go source code from the Go learning materials (Go/Baasid/cmd/hashpw/main.go).
Leggi l'articolo →
Go
go
Aggiornato 2026-04-18
main.go
main.go — go source code from the Go learning materials (Go/Baasid/cmd/server/main.go).
Leggi l'articolo →
Go
go
Aggiornato 2026-04-18
docs.go
docs.go — go source code from the Go learning materials (Go/Baasid/docs/docs.go).
Leggi l'articolo →
Go
go
Aggiornato 2026-04-18
jwt.go
jwt.go — go source code from the Go learning materials (Go/Baasid/internal/auth/jwt.go).
Leggi l'articolo →
Go
go
Aggiornato 2026-04-18
password.go
password.go — go source code from the Go learning materials (Go/Baasid/internal/auth/password.go).
Leggi l'articolo →
Go
go
Aggiornato 2026-04-18
password_test.go
password_test.go — go source code from the Go learning materials (Go/Baasid/internal/auth/password_test.go).
Leggi l'articolo →