fix: add 404 return codes, fix normalize domain
This commit is contained in:
parent
daa63016aa
commit
d55c5fa10a
2 changed files with 5 additions and 2 deletions
|
@ -78,6 +78,8 @@ func MatrixClient(w http.ResponseWriter, req *http.Request) {
|
||||||
Url: msc3575,
|
Url: msc3575,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
json.NewEncoder(w).Encode(m)
|
json.NewEncoder(w).Encode(m)
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,9 +35,7 @@ func GetNostrAddr(w http.ResponseWriter, r *http.Request) {
|
||||||
// normalize domain
|
// normalize domain
|
||||||
domain, _, err := net.SplitHostPort(r.Host)
|
domain, _, err := net.SplitHostPort(r.Host)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.Debug().Msgf("unable to split hostname %s: %s", r.Host, err.Error())
|
|
||||||
domain = r.Host
|
domain = r.Host
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// get owner id for nip05 request
|
// get owner id for nip05 request
|
||||||
|
@ -49,6 +47,7 @@ func GetNostrAddr(w http.ResponseWriter, r *http.Request) {
|
||||||
err = DB.QueryRow("SELECT pubkey, relays FROM users WHERE id=$1", uid).Scan(&user.Pubkey, &user.Relays)
|
err = DB.QueryRow("SELECT pubkey, relays FROM users WHERE id=$1", uid).Scan(&user.Pubkey, &user.Relays)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.Error().Msgf("unable to get user for uid %v: %s", uid, err.Error())
|
l.Error().Msgf("unable to get user for uid %v: %s", uid, err.Error())
|
||||||
|
w.WriteHeader(http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,6 +56,7 @@ func GetNostrAddr(w http.ResponseWriter, r *http.Request) {
|
||||||
err = DB.Select(&names, "SELECT nip05s.name FROM nip05s JOIN users ON nip05s.owner_id = users.id WHERE nip05s.owner_id = $1", uid)
|
err = DB.Select(&names, "SELECT nip05s.name FROM nip05s JOIN users ON nip05s.owner_id = users.id WHERE nip05s.owner_id = $1", uid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.Error().Msgf("unable to get user for uid %v: %s", uid, err.Error())
|
l.Error().Msgf("unable to get user for uid %v: %s", uid, err.Error())
|
||||||
|
w.WriteHeader(http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,6 +84,7 @@ func GetNostrAddr(w http.ResponseWriter, r *http.Request) {
|
||||||
j, err := json.Marshal(ret)
|
j, err := json.Marshal(ret)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.Error().Msg(err.Error())
|
l.Error().Msg(err.Error())
|
||||||
|
w.WriteHeader(http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue