Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/getalby/lsat-middleware
A middleware library for Gin and Echo framework that provides handler functions to accept microtransactions before serving ad-free content or any paid APIs.
https://github.com/getalby/lsat-middleware
gin go golang lightning-network lsat
Last synced: 20 days ago
JSON representation
A middleware library for Gin and Echo framework that provides handler functions to accept microtransactions before serving ad-free content or any paid APIs.
- Host: GitHub
- URL: https://github.com/getalby/lsat-middleware
- Owner: getAlby
- License: mit
- Created: 2022-05-26T10:48:36.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-06-26T09:24:22.000Z (over 1 year ago)
- Last Synced: 2024-11-14T14:23:20.744Z (about 1 month ago)
- Topics: gin, go, golang, lightning-network, lsat
- Language: Go
- Homepage:
- Size: 207 KB
- Stars: 9
- Watchers: 10
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# LSAT-Middleware
A middleware library for [Gin](https://github.com/gin-gonic/gin) and [Echo](https://echo.labstack.com/) framework that uses [LSAT](https://lsat.tech/) (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:-
1. Checks the preference of the user whether they need paid content or free content.
2. Verify the LSAT before serving paid content.
3. 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
1. Run this:
```
go get github.com/getAlby/lsat-middleware
```2. Create `.env` file (refer `.env_example`) and configure `LND_ADDRESS` and `MACAROON_HEX` for LND client or `LNURL_ADDRESS` for LNURL client, `LN_CLIENT_TYPE` (out of LND, LNURL) and `ROOT_KEY` (for minting macaroons).
## Usage
See the `examples` directory.
[This example](https://github.com/getAlby/lsat-middleware/blob/main/examples/ginlsat/main.go) shows how to use LSAT-Middleware with [Gin](https://github.com/gin-gonic/gin) framework for serving simple JSON response:-
[This repo](https://github.com/getAlby/lsat-proxy) demonstrates serving of static files and creating a paywall for paid resources using LSAT-Middleware.
[Nakaphoto](https://nakaphoto.vercel.app/), A platform to buy and sell images for sats made using LSAT-Middleware ([link to repo](https://github.com/getAlby/sell-lsat-files)).
## Testing
Run `go test` to run tests.