-
Notifications
You must be signed in to change notification settings - Fork 9
/
main.go
31 lines (25 loc) · 860 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package main
import (
"net/http"
"github.com/labstack/echo"
"github.com/philippgille/ln-paywall/ln"
"github.com/philippgille/ln-paywall/storage"
"github.com/philippgille/ln-paywall/wall"
)
func main() {
e := echo.New()
// Configure middleware
invoiceOptions := wall.DefaultInvoiceOptions // Price: 1 Satoshi; Memo: "API call"
lndOptions := ln.DefaultLNDoptions // Address: "localhost:10009", CertFile: "tls.cert", MacaroonFile: "invoice.macaroon"
storageClient := storage.NewGoMap() // Local in-memory cache
lnClient, err := ln.NewLNDclient(lndOptions)
if err != nil {
panic(err)
}
// Use middleware
e.Use(wall.NewEchoMiddleware(invoiceOptions, lnClient, storageClient, nil))
e.GET("/ping", func(c echo.Context) error {
return c.String(http.StatusOK, "pong")
})
e.Logger.Fatal(e.Start(":8080")) // Start server
}