Some more output so i can know whats going on

This commit is contained in:
Amarpreet Minhas 2023-05-15 21:48:45 -04:00
parent 52cd96bd7d
commit 9ecec99310
2 changed files with 9 additions and 1 deletions

4
.gitignore vendored
View file

@ -21,3 +21,7 @@
# Go workspace file # Go workspace file
go.work go.work
# binary outputs
well-goknown
cmd/lnd-verifier/lnd-verifier

View file

@ -125,7 +125,7 @@ func RequestNostrAddr(w http.ResponseWriter, r *http.Request) {
tmplt, err := template.ParseFiles("html/nostr_qr_response.html") tmplt, err := template.ParseFiles("html/nostr_qr_response.html")
if err != nil { if err != nil {
l.Error().Msg("unable to parse template") l.Error().Msg("unable to parse qr response template")
w.WriteHeader(http.StatusServiceUnavailable) w.WriteHeader(http.StatusServiceUnavailable)
json.NewEncoder(w).Encode(&jsonErrorMessage{ json.NewEncoder(w).Encode(&jsonErrorMessage{
Error: "service unavailable", Error: "service unavailable",
@ -147,6 +147,7 @@ func RequestNostrAddr(w http.ResponseWriter, r *http.Request) {
func GetNostrAddr(w http.ResponseWriter, r *http.Request) { func GetNostrAddr(w http.ResponseWriter, r *http.Request) {
ctx := context.TODO() ctx := context.TODO()
l := logger.Get()
// get query string for username // get query string for username
r.ParseForm() r.ParseForm()
requestedName := r.FormValue("name") requestedName := r.FormValue("name")
@ -158,6 +159,7 @@ func GetNostrAddr(w http.ResponseWriter, r *http.Request) {
search := getRkey("verified", requestedName, getHostname(r.Host)) search := getRkey("verified", requestedName, getHostname(r.Host))
addr, err := redisCli.Get(ctx, search).Result() addr, err := redisCli.Get(ctx, search).Result()
if err != nil { if err != nil {
l.Info().Msg(fmt.Sprintf("get %s: not found", search))
w.WriteHeader(http.StatusNotFound) w.WriteHeader(http.StatusNotFound)
json.NewEncoder(w).Encode(&jsonErrorMessage{ json.NewEncoder(w).Encode(&jsonErrorMessage{
Error: "username not registered", Error: "username not registered",
@ -166,6 +168,7 @@ func GetNostrAddr(w http.ResponseWriter, r *http.Request) {
} }
dec, err := b64.StdEncoding.DecodeString(addr) dec, err := b64.StdEncoding.DecodeString(addr)
if err != nil { if err != nil {
l.Error().Msg(fmt.Sprintf("get %s: unable to decode key", search))
w.WriteHeader(http.StatusInternalServerError) w.WriteHeader(http.StatusInternalServerError)
json.NewEncoder(w).Encode(&jsonErrorMessage{ json.NewEncoder(w).Encode(&jsonErrorMessage{
Error: "internal server error", Error: "internal server error",
@ -173,6 +176,7 @@ func GetNostrAddr(w http.ResponseWriter, r *http.Request) {
return return
} }
l.Info().Msg(fmt.Sprintf("get %s: found and returned", search))
w.Header().Set("Content-Type", "application/json") w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusOK)
w.Write(dec) w.Write(dec)