backend for xcvr appview
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

basic http endpoint stuff

+93 -22
+81 -11
server/cmd/main.go
··· 2 2 3 3 import ( 4 4 "fmt" 5 - "os" 6 - "sync" 5 + "net/http" 7 6 8 7 "github.com/rachel-mp4/lrc/lrcd/pkg/lrcd" 9 8 ) 10 9 10 + var ( 11 + channelToServer map[string]*lrcd.Server 12 + ) 13 + 11 14 func main() { 15 + channelToServer = make( map[string]*lrcd.Server) 12 16 fmt.Println("hello world") 13 - server, err := lrcd.NewServer(lrcd.WithWSPort(8080), lrcd.WithLogging(os.Stdout, true)) 14 - err = server.Start() 15 - if err != nil { 16 - fmt.Printf(err.Error()) 17 + http.HandleFunc("GET /", homeHandler) 18 + 19 + http.HandleFunc("GET /{channel}", serverStart) 20 + http.ListenAndServe(":8080", nil) 21 + } 22 + 23 + func serverStart(w http.ResponseWriter, r *http.Request) { 24 + name := r.PathValue("channel") 25 + fmt.Fprintln(w,name) 26 + _, ok := channelToServer[name] 27 + if ok { 28 + fmt.Fprint(w, "already created server") 29 + return 17 30 } 18 - var wg sync.WaitGroup 19 - wg.Add(1) 20 - wg.Wait() 21 - return 22 - } 31 + channelToServer[name] = nil 32 + fmt.Fprintln(w, "created server") 33 + // if server != nil { 34 + // fmt.Fprint(w, "server already started") 35 + // return 36 + // } 37 + // var err error 38 + // server, err = lrcd.NewServer(lrcd.WithWSPort(8080), lrcd.WithLogging(os.Stdout, true)) 39 + // if err != nil { 40 + // fmt.Println(err.Error()) 41 + // fmt.Fprintln(w, "failed to start") 42 + // return 43 + // } 44 + // err = server.Start() 45 + // if err != nil { 46 + // fmt.Println(err.Error()) 47 + // fmt.Fprintln(w, "failed to start") 48 + // return 49 + // } 50 + // fmt.Fprintln(w, "started") 51 + } 52 + 53 + func serverStop(w http.ResponseWriter, r *http.Request) { 54 + // if server == nil { 55 + // fmt.Fprintln(w, "no server to stop") 56 + // return 57 + // } 58 + // err := server.Stop() 59 + // if err != nil { 60 + // fmt.Println(err.Error()) 61 + // fmt.Fprintln(w, "failed to stop") 62 + // return 63 + // } 64 + // server = nil 65 + // fmt.Fprintln(w, "stopped") 66 + } 67 + 68 + func homeHandler(w http.ResponseWriter, r *http.Request) { 69 + fmt.Fprintln(w, "welcome") 70 + for k, _ := range channelToServer { 71 + fmt.Fprintln(w, k) 72 + } 73 + } 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 +
+6 -3
server/go.mod
··· 2 2 3 3 go 1.22.1 4 4 5 - require github.com/rachel-mp4/lrc/lrcd v0.0.0-20250407195722-5a8956062fbc 5 + require github.com/rachel-mp4/lrc/lrcd v0.0.0-20250408005617-2d344a3d04f7 6 6 7 7 require ( 8 8 github.com/gorilla/websocket v1.5.3 // indirect 9 - github.com/rachel-mp4/lrc v0.0.0-20250407195722-5a8956062fbc // indirect 10 - github.com/rachel-mp4/lrc/lrc v0.0.0-20250407195722-5a8956062fbc // indirect 9 + github.com/rachel-mp4/lrc/lrc v0.0.0-20250408005617-2d344a3d04f7 // indirect 11 10 ) 11 + 12 + replace github.com/rachel-mp4/lrc/lrcd => ../../lrc/lrcd 13 + 14 + replace github.com/rachel-mp4/lrc/lrc => ../../lrc/lrc
+6 -8
server/go.sum
··· 1 1 github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= 2 2 github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= 3 - github.com/rachel-mp4/lrc v0.0.0-20250407195722-5a8956062fbc h1:aRLZqkE/ufO7aYiWf6V5t/w89E4RwnnhUtqVe1sekhA= 4 - github.com/rachel-mp4/lrc v0.0.0-20250407195722-5a8956062fbc/go.mod h1:AFAKOwRsDDo643wKe5OBGx96yPWvZQjrGLJZ0lJex+A= 5 - github.com/rachel-mp4/lrc/lrc v0.0.0-20250407195722-5a8956062fbc h1:0ZtrSZtrWY+yaASyUh3NYy1mRjj+AgeId8+1SQh2lZQ= 6 - github.com/rachel-mp4/lrc/lrc v0.0.0-20250407195722-5a8956062fbc/go.mod h1:8gurhwhM0qJhpRw4jWNPiTureKGbtql33khlbS17ULc= 7 - github.com/rachel-mp4/lrc/lrcd v0.0.0-20250407171837-02f3816ed7ef h1:IMj8nB5q+dnCfqcmwRohXOyJf9HboQ5v2r+eNCcUWB4= 8 - github.com/rachel-mp4/lrc/lrcd v0.0.0-20250407171837-02f3816ed7ef/go.mod h1:V/dWrPAee/3ULiIjm6psRNfep1dKt+AZBGs6/2NvSC4= 9 - github.com/rachel-mp4/lrc/lrcd v0.0.0-20250407195722-5a8956062fbc h1:UM31U8CDYbtThXUTkBK7lNO3m7USqDfvFthT1pZ13FE= 10 - github.com/rachel-mp4/lrc/lrcd v0.0.0-20250407195722-5a8956062fbc/go.mod h1:V/dWrPAee/3ULiIjm6psRNfep1dKt+AZBGs6/2NvSC4= 3 + github.com/rachel-mp4/lrc/lrc v0.0.0-20250408005617-2d344a3d04f7 h1:tdZLEbrHSRIDinWVbD/g0CKY6XxcsoZ0nH5P3aW4LDU= 4 + github.com/rachel-mp4/lrc/lrc v0.0.0-20250408005617-2d344a3d04f7/go.mod h1:8gurhwhM0qJhpRw4jWNPiTureKGbtql33khlbS17ULc= 5 + github.com/rachel-mp4/lrc/lrcd v0.0.0-20250407004606-f56de1e09d2a h1:PCr+Uo6LLOG0C04xNM3Uxbu3Atw/Nm3EtfMzFoS3Gcc= 6 + github.com/rachel-mp4/lrc/lrcd v0.0.0-20250407004606-f56de1e09d2a/go.mod h1:V/dWrPAee/3ULiIjm6psRNfep1dKt+AZBGs6/2NvSC4= 7 + github.com/rachel-mp4/lrc/lrcd v0.0.0-20250408005617-2d344a3d04f7 h1:wHl6d6Zmh2ENdtod4Ibe3TmuKvkioURSVmFc+TIWzzU= 8 + github.com/rachel-mp4/lrc/lrcd v0.0.0-20250408005617-2d344a3d04f7/go.mod h1:V/dWrPAee/3ULiIjm6psRNfep1dKt+AZBGs6/2NvSC4=