reformat with gofmt
This commit is contained in:
parent
d82c17e0a1
commit
7816566d59
9 changed files with 221 additions and 216 deletions
|
|
@ -1,9 +1,9 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/gorilla/mux"
|
||||
"net/http"
|
||||
"github.com/gorilla/mux"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func lnurlp_response(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
@ -12,51 +12,51 @@ func lnurlp_response(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
name := mux.Vars(r)["name"]
|
||||
name := mux.Vars(r)["name"]
|
||||
|
||||
log.WithFields(
|
||||
log.Fields{
|
||||
"url_path": r.URL.Path,
|
||||
"name": name,
|
||||
"r.Host": r.Host,
|
||||
},).Info("lnurlp_response")
|
||||
log.WithFields(
|
||||
log.Fields{
|
||||
"url_path": r.URL.Path,
|
||||
"name": name,
|
||||
"r.Host": r.Host,
|
||||
}).Info("lnurlp_response")
|
||||
|
||||
// look up domain setting (HOST_DOMAIN)
|
||||
// look up domain setting (HOST_DOMAIN)
|
||||
|
||||
domain := db_get_setting("HOST_DOMAIN")
|
||||
if r.Host != domain {
|
||||
log.Warn("wrong host domain")
|
||||
write_error(w)
|
||||
return
|
||||
}
|
||||
domain := db_get_setting("HOST_DOMAIN")
|
||||
if r.Host != domain {
|
||||
log.Warn("wrong host domain")
|
||||
write_error(w)
|
||||
return
|
||||
}
|
||||
|
||||
// look up name in database (table cards, field card_name)
|
||||
// look up name in database (table cards, field card_name)
|
||||
|
||||
card_count, err := db_get_card_count_for_name_lnurlp(name)
|
||||
if err != nil {
|
||||
log.Warn("could not get card count for name")
|
||||
write_error(w)
|
||||
return
|
||||
}
|
||||
card_count, err := db_get_card_count_for_name_lnurlp(name)
|
||||
if err != nil {
|
||||
log.Warn("could not get card count for name")
|
||||
write_error(w)
|
||||
return
|
||||
}
|
||||
|
||||
if card_count != 1 {
|
||||
log.Info("not one enabled card with that name")
|
||||
write_error(w)
|
||||
return
|
||||
}
|
||||
if card_count != 1 {
|
||||
log.Info("not one enabled card with that name")
|
||||
write_error(w)
|
||||
return
|
||||
}
|
||||
|
||||
metadata := "[[\\\"text/identifier\\\",\\\"" + name + "@" + domain + "\\\"],[\\\"text/plain\\\",\\\"bolt card deposit\\\"]]"
|
||||
metadata := "[[\\\"text/identifier\\\",\\\"" + name + "@" + domain + "\\\"],[\\\"text/plain\\\",\\\"bolt card deposit\\\"]]"
|
||||
|
||||
jsonData := []byte(`{"status":"OK",` +
|
||||
`"callback":"https://` + domain + `/lnurlp/` + name + `",` +
|
||||
`"tag":"payRequest",` +
|
||||
`"maxSendable":1000000000,` +
|
||||
`"minSendable":1000,` +
|
||||
`"metadata":"` + metadata + `",` +
|
||||
`"commentAllowed":0` +
|
||||
`}`)
|
||||
jsonData := []byte(`{"status":"OK",` +
|
||||
`"callback":"https://` + domain + `/lnurlp/` + name + `",` +
|
||||
`"tag":"payRequest",` +
|
||||
`"maxSendable":1000000000,` +
|
||||
`"minSendable":1000,` +
|
||||
`"metadata":"` + metadata + `",` +
|
||||
`"commentAllowed":0` +
|
||||
`}`)
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.Write(jsonData)
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.Write(jsonData)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue