-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
34 lines (27 loc) · 811 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
32
33
34
package main
import (
"net/http"
"github.com/gin-gonic/gin"
"github.com/philippgille/ln-paywall/ln"
"github.com/philippgille/ln-paywall/storage"
"github.com/philippgille/ln-paywall/wall"
)
func main() {
r := gin.Default()
// Configure middleware
invoiceOptions := wall.DefaultInvoiceOptions // Price: 1 Satoshi; Memo: "API call"
chargeOptions := ln.ChargeOptions{ // Address: "http://localhost:9112"
APItoken: "secret",
}
storageClient := storage.NewGoMap() // Local in-memory cache
lnClient, err := ln.NewChargeClient(chargeOptions)
if err != nil {
panic(err)
}
// Use middleware
r.Use(wall.NewGinMiddleware(invoiceOptions, lnClient, storageClient))
r.GET("/ping", func(c *gin.Context) {
c.String(http.StatusOK, "pong")
})
r.Run() // Listen and serve on 0.0.0.0:8080
}