Add nostr nip-05 registration with lnd invoices #1
1 changed files with 22 additions and 17 deletions
|
@ -6,28 +6,13 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"git.minhas.io/asara/well-goknown/config"
|
"git.minhas.io/asara/well-goknown/config"
|
||||||
|
"git.minhas.io/asara/well-goknown/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
type matrixServerWellKnown struct {
|
type matrixServerWellKnown struct {
|
||||||
WellKnownAddress string `json:"m.server"`
|
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 {
|
type matrixBaseUrl struct {
|
||||||
BaseUrl string `json:"base_url"`
|
BaseUrl string `json:"base_url"`
|
||||||
}
|
}
|
||||||
|
@ -41,11 +26,31 @@ type matrixClientWellKnown struct {
|
||||||
IdentityServer *matrixIdentityServer `json:"m.identity_server,omitempty"`
|
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
|
// uses an environment variable for now
|
||||||
wellKnownAddr := config.GetConfig().MatrixWellKnownAddress
|
wellKnownAddr := config.GetConfig().MatrixWellKnownAddress
|
||||||
if wellKnownAddr == "" {
|
if wellKnownAddr == "" {
|
||||||
w.WriteHeader(http.StatusNotFound)
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue