28 lines
552 B
Go
28 lines
552 B
Go
package matrix
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
"os"
|
|
)
|
|
|
|
type matrixWellKnown struct {
|
|
WellKnownAddress string `json:"m.server"`
|
|
}
|
|
|
|
func Matrix(w http.ResponseWriter, req *http.Request) {
|
|
// uses an environment variable for now
|
|
wellKnownAddr, ok := os.LookupEnv("MATRIX_WELL_KNOWN_ADDRESS")
|
|
if !ok {
|
|
w.WriteHeader(http.StatusNotFound)
|
|
return
|
|
}
|
|
|
|
w.Header().Set("Content-Type", "application/json")
|
|
w.WriteHeader(http.StatusOK)
|
|
wellKnown := &matrixWellKnown{
|
|
WellKnownAddress: wellKnownAddr,
|
|
}
|
|
json.NewEncoder(w).Encode(wellKnown)
|
|
}
|