add redirect paths

This commit is contained in:
bitkarrot 2023-03-02 22:10:18 -08:00
commit 1176fd0322
2 changed files with 18 additions and 0 deletions

View file

@ -17,6 +17,17 @@ lnurlp_static_files = [
"name": "lnurlp_static", "name": "lnurlp_static",
} }
] ]
lnurlp_redirect_paths = [
{
"from_path": "/.well-known/lnurlp",
"redirect_to_path": "/api/v1/well-known",
"header_filters": {
"accept": "application/json"
}
}
]
scheduled_tasks: List[asyncio.Task] = [] scheduled_tasks: List[asyncio.Task] = []
lnurlp_ext: APIRouter = APIRouter(prefix="/lnurlp", tags=["lnurlp"]) lnurlp_ext: APIRouter = APIRouter(prefix="/lnurlp", tags=["lnurlp"])

View file

@ -1,6 +1,7 @@
import json import json
from asyncio.log import logger from asyncio.log import logger
from http import HTTPStatus from http import HTTPStatus
from urllib.parse import urlparse
from fastapi import Depends, Query, Request from fastapi import Depends, Query, Request
from lnurl.exceptions import InvalidUrl as LnurlInvalidUrl from lnurl.exceptions import InvalidUrl as LnurlInvalidUrl
@ -19,6 +20,12 @@ from .crud import (
update_pay_link, update_pay_link,
) )
from .models import CreatePayLinkData from .models import CreatePayLinkData
from .lnurl import lnurl_response
@lnurlp_ext.get("/api/v1/well-known/{username}")
async def lnaddress(username: str, request: Request):
domain = urlparse(str(request.url)).netloc
return await lnurl_response(username, domain, request)
@lnurlp_ext.get("/api/v1/currencies") @lnurlp_ext.get("/api/v1/currencies")