well-goknown/main.go
2023-05-01 18:41:28 -04:00

50 lines
1.4 KiB
Go

package main
import (
"net/http"
"git.minhas.io/asara/well-goknown/config"
"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")
}
/*
nostrTest := nostr.NostrRequest{
Name: "asara",
Key: "npub180cvv07tjdrrgpa0j7j7tmnyl2yr6yr7l8j4s3evf6u64th6gkwsyjh6w6",
Hostname: "devvul.com",
}
nostr.AddNostrAddr(nostrTest)
*/
// 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)
l.Debug().Msg("enabling nostr request endpoint")
http.HandleFunc("/request/nostr", nostr.RequestNostrAddr)
// start server
port := config.GetConfig().ListenAddr
l.Info().Msgf("starting server on %s", port)
http.ListenAndServe(port, nil)
}