chore: proper 404s

This commit is contained in:
Amarpreet Minhas 2024-08-11 00:03:19 -04:00
parent d55c5fa10a
commit 36d59958b6
2 changed files with 5 additions and 5 deletions

View file

@ -36,8 +36,8 @@ func MatrixServer(w http.ResponseWriter, req *http.Request) {
// uses an environment variable for now
wellKnownAddr := fmt.Sprintf("%s:8448", config.GetConfig().MatrixWellKnownAddress)
if wellKnownAddr == "" {
w.WriteHeader(http.StatusNotFound)
l.Debug().Str("path", "matrix/server").Msg("matrix well known address unset")
http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)
return
}
@ -56,8 +56,8 @@ func MatrixClient(w http.ResponseWriter, req *http.Request) {
wellKnownAddr := config.GetConfig().MatrixWellKnownAddress
// no matrix config set
if wellKnownAddr == "" {
w.WriteHeader(http.StatusNotFound)
l.Debug().Str("path", "matrix/client").Msg("matrix well known address unset")
http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)
return
}

View file

@ -47,7 +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)
if err != nil {
l.Error().Msgf("unable to get user for uid %v: %s", uid, err.Error())
w.WriteHeader(http.StatusNotFound)
http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)
return
}
@ -56,7 +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)
if err != nil {
l.Error().Msgf("unable to get user for uid %v: %s", uid, err.Error())
w.WriteHeader(http.StatusNotFound)
http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)
return
}
@ -84,7 +84,7 @@ func GetNostrAddr(w http.ResponseWriter, r *http.Request) {
j, err := json.Marshal(ret)
if err != nil {
l.Error().Msg(err.Error())
w.WriteHeader(http.StatusNotFound)
http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)
return
}