well-goknown/main.go

34 lines
883 B
Go

package main
import (
"net/http"
"git.minhas.io/asara/gologger"
"git.minhas.io/asara/well-goknown/config"
"git.minhas.io/asara/well-goknown/db"
"git.minhas.io/asara/well-goknown/matrix"
"git.minhas.io/asara/well-goknown/nostr"
)
func main() {
l := gologger.Get(config.GetConfig().LogLevel).With().Str("context", "main").Logger()
db, _ := db.NewDB()
defer db.Close()
nostr.DB = db
// matrix endpoints
l.Debug().Msg("enabling matrix well-known endpoints")
http.HandleFunc("/.well-known/matrix/server", matrix.MatrixServer)
http.HandleFunc("/.well-known/matrix/client", matrix.MatrixClient)
// nostr endpoints
l.Debug().Msg("enabling nostr well-known endpoints")
http.HandleFunc("/.well-known/nostr.json", nostr.GetNostrAddr)
// start server
port := config.GetConfig().ListenAddr
l.Info().Msgf("starting server on %s", port)
http.ListenAndServe(port, nil)
}