Skip to content

Commit

Permalink
Tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
gofeuer committed Aug 8, 2024
1 parent 985ac21 commit b3ed6fe
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (m YourMacaroonMinter) MintWithChallenge(r *http.Request) (string, l402.Cha

macaroonsBase64, _ := l402.MarshalMacaroons(mac) // Accepts multiple macaroons

// Provide an invoice from your lighting node that reveals the secret matching paymentHash
// Provide an invoice from your lighting node that reveals the secret matching paymentHash
challenge := l402.Invoice("lnbc20m1pvjluezpp5q...")

return macaroonsBase64, challenge, nil
Expand All @@ -62,7 +62,6 @@ type YourAccessAuthority struct {
}

func (m YourAccessAuthority) ApproveAccess(r *http.Request, macaroons map[l402.Identifier]*macaroon.Macaroon) l402.Rejection {

for identifier, macaroon := range macaroons {
// Verify if macaroon is singed by the correct rootKey
}
Expand All @@ -80,13 +79,13 @@ func (m YourAccessAuthority) ApproveAccess(r *http.Request, macaroons map[l402.I
import "github.com/gofeuer/l402"

func main() {
minter := YourMacaroonMinter{} // Your l402.MacaroonMinter implementation
minter := YourMacaroonMinter{} // Your l402.MacaroonMinter implementation
authorizer := YourAccessAuthority{} // Your l402.AccessAuthority implementation

// Create a L402 proxy by passing a l402.MacaroonMinter and a l402.AccessAuthority
// Create a L402 proxy by passing a l402.MacaroonMinter and a l402.AccessAuthority
proxy := l402.Proxy(minter, authorizer)

// Use `proxy` as a middleware to endpoints that require payment
// Use `proxy` as a middleware to endpoints that require payment
http.Handle("GET /", proxy(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "premium content")
})))
Expand All @@ -99,4 +98,4 @@ func main() {
Pull requests are welcome! If you have ideas for enhancing L402 Core, feel free to fork the repo and submit your changes.


**L402:** Because paying for content should be as smooth as a Lightning bolt. ⚡️🌐
**L402** | Because paying for content should be as smooth as a Lightning bolt. ⚡️🌐

0 comments on commit b3ed6fe

Please sign in to comment.