new packages

This commit is contained in:
Peter Rounce 2023-02-18 14:44:01 +00:00
parent aa5ccaded0
commit 4f4e320999
8 changed files with 83 additions and 70 deletions

24
main.go
View file

@ -6,24 +6,12 @@ import (
"net/http"
"time"
"github.com/boltcard/boltcard/db"
"github.com/boltcard/boltcard/lnurlw"
"github.com/boltcard/boltcard/lnurlp"
)
var router = mux.NewRouter()
func write_error(w http.ResponseWriter) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
jsonData := []byte(`{"status":"ERROR","reason":"bad request"}`)
w.Write(jsonData)
}
func write_error_message(w http.ResponseWriter, message string) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
jsonData := []byte(`{"status":"ERROR","reason":"` + message + `"}`)
w.Write(jsonData)
}
func main() {
log_level := db.Get_setting("LOG_LEVEL")
@ -45,11 +33,11 @@ func main() {
// createboltcard
router.Path("/new").Methods("GET").HandlerFunc(new_card_request)
// lnurlw for pos
router.Path("/ln").Methods("GET").HandlerFunc(lnurlw_response)
router.Path("/cb").Methods("GET").HandlerFunc(lnurlw_callback)
router.Path("/ln").Methods("GET").HandlerFunc(lnurlw.Response)
router.Path("/cb").Methods("GET").HandlerFunc(lnurlw.Callback)
// lnurlp for lightning address
router.Path("/.well-known/lnurlp/{name}").Methods("GET").HandlerFunc(lnurlp_response)
router.Path("/lnurlp/{name}").Methods("GET").HandlerFunc(lnurlp_callback)
router.Path("/.well-known/lnurlp/{name}").Methods("GET").HandlerFunc(lnurlp.Response)
router.Path("/lnurlp/{name}").Methods("GET").HandlerFunc(lnurlp.Callback)
port := db.Get_setting("HOST_PORT")
if port == "" {