From 4747b15d62151e41f05e0f42700b992b77647476 Mon Sep 17 00:00:00 2001 From: Asara Date: Sat, 29 Apr 2023 14:01:52 -0400 Subject: [PATCH] Update matrix.go to use new logger, fix up outputs --- matrix/matrix.go | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/matrix/matrix.go b/matrix/matrix.go index ab378dc..cfb927b 100644 --- a/matrix/matrix.go +++ b/matrix/matrix.go @@ -6,28 +6,13 @@ import ( "net/http" "git.minhas.io/asara/well-goknown/config" + "git.minhas.io/asara/well-goknown/logger" ) type matrixServerWellKnown struct { WellKnownAddress string `json:"m.server"` } -func MatrixServer(w http.ResponseWriter, req *http.Request) { - // uses an environment variable for now - wellKnownAddr := config.GetConfig().MatrixWellKnownAddress - if wellKnownAddr == "" { - w.WriteHeader(http.StatusNotFound) - return - } - - w.Header().Set("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - wellKnown := &matrixServerWellKnown{ - WellKnownAddress: wellKnownAddr, - } - json.NewEncoder(w).Encode(wellKnown) -} - type matrixBaseUrl struct { BaseUrl string `json:"base_url"` } @@ -41,11 +26,31 @@ type matrixClientWellKnown struct { IdentityServer *matrixIdentityServer `json:"m.identity_server,omitempty"` } -func MatrixClient(w http.ResponseWriter, req *http.Request) { +func MatrixServer(w http.ResponseWriter, req *http.Request) { + l := logger.Get() // uses an environment variable for now wellKnownAddr := config.GetConfig().MatrixWellKnownAddress if wellKnownAddr == "" { w.WriteHeader(http.StatusNotFound) + l.Debug().Str("path", "matrix/server").Msg("matrix well known address unset") + return + } + + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusOK) + wellKnown := &matrixServerWellKnown{ + WellKnownAddress: wellKnownAddr, + } + json.NewEncoder(w).Encode(wellKnown) +} + +func MatrixClient(w http.ResponseWriter, req *http.Request) { + l := logger.Get() + // uses an environment variable for now + wellKnownAddr := config.GetConfig().MatrixWellKnownAddress + if wellKnownAddr == "" { + w.WriteHeader(http.StatusNotFound) + l.Debug().Str("path", "matrix/client").Msg("matrix well known address unset") return }