2023-01-25 05:47:06 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
2024-08-10 23:55:16 +00:00
|
|
|
"git.minhas.io/asara/gologger"
|
2023-04-29 18:01:40 +00:00
|
|
|
"git.minhas.io/asara/well-goknown/config"
|
2024-08-10 23:55:16 +00:00
|
|
|
"git.minhas.io/asara/well-goknown/db"
|
2023-01-25 05:47:06 +00:00
|
|
|
"git.minhas.io/asara/well-goknown/matrix"
|
|
|
|
"git.minhas.io/asara/well-goknown/nostr"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2024-08-10 23:55:16 +00:00
|
|
|
l := gologger.Get(config.GetConfig().LogLevel).With().Str("context", "main").Logger()
|
|
|
|
db, _ := db.NewDB()
|
|
|
|
defer db.Close()
|
|
|
|
|
|
|
|
nostr.DB = db
|
2023-05-06 23:50:10 +00:00
|
|
|
|
2023-02-03 04:56:15 +00:00
|
|
|
// matrix endpoints
|
2024-08-10 23:55:16 +00:00
|
|
|
l.Debug().Msg("enabling matrix well-known endpoints")
|
2023-02-04 01:15:41 +00:00
|
|
|
http.HandleFunc("/.well-known/matrix/server", matrix.MatrixServer)
|
|
|
|
http.HandleFunc("/.well-known/matrix/client", matrix.MatrixClient)
|
2023-02-03 04:56:15 +00:00
|
|
|
|
|
|
|
// nostr endpoints
|
2024-08-10 23:55:16 +00:00
|
|
|
l.Debug().Msg("enabling nostr well-known endpoints")
|
2023-01-25 05:47:06 +00:00
|
|
|
http.HandleFunc("/.well-known/nostr.json", nostr.GetNostrAddr)
|
2023-12-31 01:12:01 +00:00
|
|
|
|
2023-02-03 04:56:15 +00:00
|
|
|
// start server
|
2023-04-29 18:01:40 +00:00
|
|
|
port := config.GetConfig().ListenAddr
|
|
|
|
l.Info().Msgf("starting server on %s", port)
|
|
|
|
http.ListenAndServe(port, nil)
|
2023-01-25 05:47:06 +00:00
|
|
|
}
|