relay admin service
relay atprotocol backend golang

some initial plans #1

merged opened by besaid.zone targeting main from push-qzkqlxrpnmlm
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:qttsv4e7pu2jl3ilanfgc3zn/sh.tangled.repo.pull/3mbztk2khcm22
+47 -2
Diff #0
+47 -2
main.go
··· 1 1 package main 2 2 3 - import "fmt" 3 + import ( 4 + "fmt" 5 + "log" 6 + "log/slog" 7 + "net/http" 8 + "os" 9 + "time" 10 + ) 11 + 12 + type Server struct { 13 + addr string 14 + } 4 15 5 16 func main() { 6 - fmt.Prinln("yo") 17 + server := Server{ 18 + addr: ":8080", 19 + } 20 + 21 + logger := slog.New(slog.NewJSONHandler(os.Stdout, nil)) 22 + logger.Info(fmt.Sprintf("scatter server started at 0.0.0.0%s", server.addr)) 23 + 24 + if err := server.start(); err != nil { 25 + log.Fatal(err) 26 + os.Exit(-1) 27 + } 28 + 29 + } 30 + 31 + func (s *Server) start() error { 32 + router := http.NewServeMux() 33 + 34 + router.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) { 35 + w.WriteHeader(200) 36 + w.Write([]byte("Welcome to scatter")) 37 + }) 38 + 39 + router.HandleFunc("POST /xrpc/com.atproto.sync.requestCrawlBroadcast", func(w http.ResponseWriter, req *http.Request) { 40 + // forward requestCrawl request to list of relays that this service knows about 41 + }) 42 + 43 + server := http.Server{ 44 + Addr: s.addr, 45 + WriteTimeout: 5 * time.Second, 46 + ReadTimeout: 10 * time.Second, 47 + IdleTimeout: 30 * time.Second, 48 + Handler: router, 49 + } 50 + 51 + return server.ListenAndServe() 7 52 }

History

1 round 0 comments
sign up or login to add to the discussion
besaid.zone submitted #0
1 commit
expand
iterating on some ideas
expand 0 comments
pull request successfully merged