mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-27 08:09:58 +00:00
TUN-3500: Integrate replace h2mux by http2 work with multiple origin support
This commit is contained in:
@@ -22,6 +22,7 @@ const (
|
||||
UptimeRoute = "/uptime"
|
||||
WSRoute = "/ws"
|
||||
SSERoute = "/sse"
|
||||
HealthRoute = "/_health"
|
||||
defaultSSEFreq = time.Second * 10
|
||||
)
|
||||
|
||||
@@ -114,6 +115,7 @@ func StartHelloWorldServer(logger logger.Service, listener net.Listener, shutdow
|
||||
muxer.HandleFunc(UptimeRoute, uptimeHandler(time.Now()))
|
||||
muxer.HandleFunc(WSRoute, websocketHandler(logger, upgrader))
|
||||
muxer.HandleFunc(SSERoute, sseHandler(logger))
|
||||
muxer.HandleFunc(HealthRoute, healthHandler())
|
||||
muxer.HandleFunc("/", rootHandler(serverName))
|
||||
httpServer := &http.Server{Addr: listener.Addr().String(), Handler: muxer}
|
||||
go func() {
|
||||
@@ -221,6 +223,12 @@ func sseHandler(logger logger.Service) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
func healthHandler() http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write([]byte("ok"))
|
||||
}
|
||||
}
|
||||
|
||||
func rootHandler(serverName string) http.HandlerFunc {
|
||||
responseTemplate := template.Must(template.New("index").Parse(indexTemplate))
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
|
Reference in New Issue
Block a user