Use respond_to for request formats
This commit is contained in:
parent
07fe8dba71
commit
332ad757a5
@ -17,39 +17,40 @@ class Services::LightningController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def qr_lnurlp
|
def qr_lnurlp
|
||||||
lnurlp_url = "https://kosmos.org/.well-known/lnurlp/#{current_user.cn}"
|
respond_to do |format|
|
||||||
lnurlp_bech32 = Lnurl.new(lnurlp_url).to_bech32
|
lnurlp_url = "https://kosmos.org/.well-known/lnurlp/#{current_user.cn}"
|
||||||
qr_code = RQRCode::QRCode.new("lightning:" + lnurlp_bech32)
|
lnurlp_bech32 = Lnurl.new(lnurlp_url).to_bech32
|
||||||
|
qr_code = RQRCode::QRCode.new("lightning:" + lnurlp_bech32)
|
||||||
|
|
||||||
if params[:format] == "svg"
|
format.svg do
|
||||||
qr_svg = qr_code.as_svg(
|
qr_svg = qr_code.as_svg(
|
||||||
color: "000",
|
color: "000",
|
||||||
shape_rendering: "crispEdges",
|
shape_rendering: "crispEdges",
|
||||||
module_size: 6,
|
module_size: 6,
|
||||||
standalone: true,
|
standalone: true,
|
||||||
use_path: true,
|
use_path: true,
|
||||||
svg_attributes: {
|
svg_attributes: {
|
||||||
class: 'inline-block'
|
class: 'inline-block'
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
send_data(
|
send_data(
|
||||||
qr_svg,
|
qr_svg,
|
||||||
filename: "bitcoin-lightning-#{current_user.address}.svg",
|
filename: "bitcoin-lightning-#{current_user.address}.svg",
|
||||||
type: "image/svg+xml"
|
type: "image/svg+xml"
|
||||||
)
|
)
|
||||||
elsif params[:format] == "png"
|
end
|
||||||
qr_png = qr_code.as_png(
|
format.png do
|
||||||
fill: "white",
|
qr_png = qr_code.as_png(
|
||||||
color: "black",
|
fill: "white",
|
||||||
size: 1024,
|
color: "black",
|
||||||
)
|
size: 1024,
|
||||||
send_data(
|
)
|
||||||
qr_png,
|
send_data(
|
||||||
filename: "bitcoin-lightning-#{current_user.address}.png",
|
qr_png,
|
||||||
type: "image/png"
|
filename: "bitcoin-lightning-#{current_user.address}.png",
|
||||||
)
|
type: "image/png"
|
||||||
else
|
)
|
||||||
http_status :not_found
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user