Adapts a Gin router so payutils can register provider callback routes on it.
Standard-library http.HandlerFuncs are bridged to Gin via gin.WrapH.
go.gh.ink/payutils/http/gin/v3
go get go.gh.ink/payutils/http/gin/v3Blank-import the driver (it self-registers under the name gin) and pass a Gin
router (*gin.Engine or a route group) in Config.Instances:
import (
"github.com/gin-gonic/gin"
"go.gh.ink/payutils/v3/client"
"go.gh.ink/payutils/v3/model"
httpGin "go.gh.ink/payutils/http/gin/v3"
_ "go.gh.ink/payutils/pay/alipay/v3"
)
r := gin.New()
c, err := client.NewClient(model.Config{
Endpoint: "https://api.example.com",
Instances: model.I{httpGin.Name: r}, // *gin.Engine or *gin.RouterGroup
Credentials: model.C{ /* ... */ },
Contract: myContract{},
})payutils then registers POST /{provider}/callback on the router for each
configured provider.
Anything implementing gin.IRoutes — *gin.Engine and *gin.RouterGroup.
Passing an unsupported value makes NewInstance return
errors.ErrUnsupportedInstance.
Get · Post · Put · Patch · Delete · Head · Options · Any.
See LICENSE.