well-goknown/main.go
2023-12-31 20:09:37 -05:00

57 lines
1.6 KiB
Go

package main
import (
"net/http"
"git.minhas.io/asara/well-goknown/config"
"git.minhas.io/asara/well-goknown/lnurlp"
"git.minhas.io/asara/well-goknown/logger"
"git.minhas.io/asara/well-goknown/matrix"
"git.minhas.io/asara/well-goknown/nostr"
"git.minhas.io/asara/well-goknown/redis"
)
func main() {
var err error
l := logger.Get()
// connect to redis
redis.NostrRedisConn, err = redis.New("localhost:6379", "", redis.NostrKeyspace)
if err != nil {
l.Fatal().Msg("unable to connect to redis")
}
redis.LndRedisConn, err = redis.New("localhost:6379", "", redis.LndKeyspace)
if err != nil {
l.Fatal().Msg("unable to connect to redis")
}
redis.LnurlpRedisConn, err = redis.New("localhost:6379", "", redis.LnurlpKeyspace)
if err != nil {
l.Fatal().Msg("unable to connect to redis")
}
// matrix endpoints
l.Debug().Msg("enabling matrix server endpoint")
http.HandleFunc("/.well-known/matrix/server", matrix.MatrixServer)
l.Debug().Msg("enabling matrix client endpoint")
http.HandleFunc("/.well-known/matrix/client", matrix.MatrixClient)
// nostr endpoints
l.Debug().Msg("enabling nostr user endpoint")
http.HandleFunc("/.well-known/nostr.json", nostr.GetNostrAddr)
// enable requesting of nostr addresses
lndAddr := config.GetConfig().LndAddr
if lndAddr != "" {
l.Debug().Msg("enabling nostr request endpoint")
http.HandleFunc("/request/nostr", nostr.RequestNostrAddr)
}
//lnurlp endpoints
l.Debug().Msg("enabling lnurlp endpoint")
http.HandleFunc("/.well-known/lnurlp/", lnurlp.GetLnurlpUser)
// start server
port := config.GetConfig().ListenAddr
l.Info().Msgf("starting server on %s", port)
http.ListenAndServe(port, nil)
}