Skip to content

getAlby/lsat-middleware

Repository files navigation

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:-

  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
  1. 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 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.

About

A middleware library for Gin and Echo framework that provides handler functions to accept microtransactions before serving ad-free content or any paid APIs.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages