From 36d59958b620b6f656497e0e3ea43dd5cce83078 Mon Sep 17 00:00:00 2001 From: Asara Date: Sun, 11 Aug 2024 00:03:19 -0400 Subject: [PATCH] chore: proper 404s --- matrix/matrix.go | 4 ++-- nostr/nostr.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/matrix/matrix.go b/matrix/matrix.go index d146eb5..fdbb4e7 100644 --- a/matrix/matrix.go +++ b/matrix/matrix.go @@ -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 } diff --git a/nostr/nostr.go b/nostr/nostr.go index c86b48c..4d91a2c 100644 --- a/nostr/nostr.go +++ b/nostr/nostr.go @@ -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 }