-
Notifications
You must be signed in to change notification settings - Fork 9
/
main.go
35 lines (30 loc) · 797 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
35
package main
import (
"fmt"
"io/ioutil"
"github.com/philippgille/ln-paywall/ln"
"github.com/philippgille/ln-paywall/pay"
)
func main() {
// Set up client
lndOptions := ln.LNDoptions{ // Default address: "localhost:10009", CertFile: "tls.cert"
MacaroonFile: "admin.macaroon", // admin.macaroon is required for making payments
}
lnClient, err := ln.NewLNDclient(lndOptions)
if err != nil {
panic(err)
}
client := pay.NewClient(nil, lnClient) // Uses http.DefaultClient if no http.Client is passed
// Send request to an ln-paywalled API
res, err := client.Get("http://localhost:8080/ping")
if err != nil {
panic(err)
}
defer res.Body.Close()
// Print response body
resBody, err := ioutil.ReadAll(res.Body)
if err != nil {
panic(err)
}
fmt.Println(string(resBody))
}