LSAT-Middleware
A middleware library for Gin and Echo framework that uses LSAT (a protocol standard for authentication and paid APIs) and provides handler functions to accept microtransactions before serving ad-free content or any paid APIs.
The middleware:-
- Checks the preference of the user whether they need paid content or free content.
- Verify the LSAT before serving paid content.
- Send macaroon and invoice if the user prefers paid content and fails to present a valid LSAT.
Installation
Assuming you've installed Go and Gin
- Run this:
go get github.com/getAlby/lsat-middleware
- Create
.env
file (refer.env_example
) and configureLND_ADDRESS
andMACAROON_HEX
for LND client orLNURL_ADDRESS
for LNURL client,LN_CLIENT_TYPE
(out of LND, LNURL) andROOT_KEY
(for minting macaroons).
Usage
See the examples
directory.
This example shows how to use LSAT-Middleware with Gin framework for serving simple JSON response:-
This repo demonstrates serving of static files and creating a paywall for paid resources using LSAT-Middleware.
Nakaphoto, A platform to buy and sell images for sats made using LSAT-Middleware (link to repo).
Testing
Run go test
to run tests.