cic-custodial/cmd/init_api.go
Mohammed Sohail 2ca0d23c3c
feat: add transfer handler and input validation
* validate incoming api requests
* fix transfer ABI encoder
2022-11-30 15:18:01 +00:00

41 lines
841 B
Go

package main
import (
"net/http"
"github.com/arl/statsviz"
"github.com/go-playground/validator"
"github.com/grassrootseconomics/cic-custodial/internal/api"
"github.com/labstack/echo/v4"
)
func initApiServer() *echo.Echo {
server := echo.New()
server.HideBanner = true
server.HidePort = true
if ko.Bool("service.statsviz_debug") {
statsVizMux := http.NewServeMux()
_ = statsviz.Register(statsVizMux)
server.GET("/debug/statsviz/", echo.WrapHandler(statsVizMux))
server.GET("/debug/statsviz/*", echo.WrapHandler(statsVizMux))
}
server.Validator = &api.CustomValidator{
Validator: validator.New(),
}
apiRoute := server.Group("/api")
apiRoute.POST("/register", api.RegistrationHandler(
taskerClient,
postgresKeystore,
))
apiRoute.POST("/transfer", api.TransferHandler(
taskerClient,
))
return server
}