mirror of
https://github.com/getAlby/lndhub.go.git
synced 2025-12-23 23:55:02 +01:00
v2 api
This commit is contained in:
31
main.go
31
main.go
@@ -146,38 +146,11 @@ func main() {
|
||||
}
|
||||
|
||||
strictRateLimitMiddleware := createRateLimitMiddleware(c.StrictRateLimit, c.BurstRateLimit)
|
||||
// Public endpoints for account creation and authentication
|
||||
e.POST("/auth", controllers.NewAuthController(svc).Auth)
|
||||
e.POST("/create", controllers.NewCreateUserController(svc).CreateUser, strictRateLimitMiddleware)
|
||||
e.POST("/invoice/:user_login", controllers.NewInvoiceController(svc).Invoice, middleware.RateLimiter(middleware.NewRateLimiterMemoryStore(rate.Limit(c.DefaultRateLimit))))
|
||||
|
||||
// Secured endpoints which require a Authorization token (JWT)
|
||||
secured := e.Group("", tokens.Middleware(c.JWTSecret), middleware.RateLimiter(middleware.NewRateLimiterMemoryStore(rate.Limit(c.DefaultRateLimit))))
|
||||
securedWithStrictRateLimit := e.Group("", tokens.Middleware(c.JWTSecret), strictRateLimitMiddleware)
|
||||
secured.POST("/addinvoice", controllers.NewAddInvoiceController(svc).AddInvoice)
|
||||
securedWithStrictRateLimit.POST("/payinvoice", controllers.NewPayInvoiceController(svc).PayInvoice)
|
||||
secured.GET("/gettxs", controllers.NewGetTXSController(svc).GetTXS)
|
||||
secured.GET("/getuserinvoices", controllers.NewGetTXSController(svc).GetUserInvoices)
|
||||
secured.GET("/checkpayment/:payment_hash", controllers.NewCheckPaymentController(svc).CheckPayment)
|
||||
secured.GET("/balance", controllers.NewBalanceController(svc).Balance)
|
||||
secured.GET("/getinfo", controllers.NewGetInfoController(svc).GetInfo, createCacheClient().Middleware())
|
||||
securedWithStrictRateLimit.POST("/keysend", controllers.NewKeySendController(svc).KeySend)
|
||||
|
||||
// These endpoints are currently not supported and we return a blank response for backwards compatibility
|
||||
blankController := controllers.NewBlankController(svc)
|
||||
secured.GET("/getbtc", blankController.GetBtc)
|
||||
secured.GET("/getpending", blankController.GetPending)
|
||||
|
||||
//Index page endpoints, no Authorization required
|
||||
homeController := controllers.NewHomeController(svc, indexHtml)
|
||||
e.GET("/", homeController.Home, createCacheClient().Middleware())
|
||||
e.GET("/qr", homeController.QR)
|
||||
//workaround, just adding /static would make a request to these resources hit the authorized group
|
||||
e.GET("/static/css/*", echo.WrapHandler(http.FileServer(http.FS(staticContent))))
|
||||
e.GET("/static/img/*", echo.WrapHandler(http.FileServer(http.FS(staticContent))))
|
||||
e.Pre(middleware.Rewrite(map[string]string{
|
||||
"/favicon.ico": "/static/img/favicon.png",
|
||||
}))
|
||||
RegisterLegacyEndpoints(svc, e, secured, securedWithStrictRateLimit, strictRateLimitMiddleware)
|
||||
RegisterV2Endpoints(svc, e, secured, securedWithStrictRateLimit, strictRateLimitMiddleware)
|
||||
|
||||
//invoice streaming
|
||||
//Authentication should be done through the query param because this is a websocket
|
||||
|
||||
Reference in New Issue
Block a user