add: in production
This commit is contained in:
+5
-13
@@ -1,7 +1,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
@@ -10,8 +9,6 @@ import (
|
||||
"github.com/chathaway-codes/home-sensors/v2/pkg/signaler"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
"github.com/rs/cors"
|
||||
"golang.org/x/net/http2"
|
||||
"golang.org/x/net/http2/h2c"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -19,15 +16,8 @@ func main() {
|
||||
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()))
|
||||
|
||||
corsHandler := cors.New(cors.Options{
|
||||
@@ -35,7 +25,7 @@ func main() {
|
||||
http.MethodGet,
|
||||
http.MethodPost,
|
||||
},
|
||||
AllowedOrigins: []string{"example.com"},
|
||||
AllowedOrigins: []string{"*"},
|
||||
AllowedHeaders: []string{
|
||||
"Accept-Encoding",
|
||||
"Authorization",
|
||||
@@ -61,10 +51,12 @@ func main() {
|
||||
|
||||
server := &http.Server{
|
||||
Addr: "0.0.0.0:8080",
|
||||
Handler: h2c.NewHandler(handler, &http2.Server{}),
|
||||
Handler: handler,
|
||||
//Handler: h2c.NewHandler(handler, &http2.Server{}),
|
||||
|
||||
}
|
||||
|
||||
if err := server.ListenAndServe(); err != nil {
|
||||
if err := server.ListenAndServeTLS("server.crt", "server.key"); err != nil {
|
||||
log.Fatalf("Failed to listen for HTTP traffic: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user