add: signal server
This commit is contained in:
+27
-2
@@ -1,7 +1,32 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"connectrpc.com/grpcreflect"
|
||||
servicepb "github.com/chathaway-codes/home-sensors/v2/gen/genconnect"
|
||||
"github.com/chathaway-codes/home-sensors/v2/pkg/signaler"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Printf("Hello world!\n")
|
||||
mux := http.NewServeMux()
|
||||
reflector := grpcreflect.NewStaticReflector(
|
||||
servicepb.SignalerServiceName,
|
||||
)
|
||||
path, _ := grpcreflect.NewHandlerV1(reflector)
|
||||
fmt.Printf("Got path %s\n", path)
|
||||
mux.Handle(grpcreflect.NewHandlerV1(reflector))
|
||||
path, _ = grpcreflect.NewHandlerV1Alpha(reflector)
|
||||
fmt.Printf("Got path %s\n", path)
|
||||
mux.Handle(grpcreflect.NewHandlerV1Alpha(reflector))
|
||||
|
||||
path, _ = servicepb.NewSignalerServiceHandler(signaler.New())
|
||||
fmt.Printf("Got path %s\n", path)
|
||||
mux.Handle(servicepb.NewSignalerServiceHandler(signaler.New()))
|
||||
|
||||
if err := http.ListenAndServe("127.0.0.1:8080", mux); err != nil {
|
||||
log.Fatalf("Failed to listen for HTTP traffic: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user