| 
															
																@@ -4,6 +4,7 @@ import ( 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 	"io" 
															 | 
															
															 | 
															
																 	"io" 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 	"log" 
															 | 
															
															 | 
															
																 	"log" 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 	"net/http" 
															 | 
															
															 | 
															
																 	"net/http" 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+	"strings" 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 	"sync" 
															 | 
															
															 | 
															
																 	"sync" 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 ) 
															 | 
															
															 | 
															
																 ) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																  
															 | 
															
															 | 
															
																  
															 | 
														
													
												
											
												
													
														
															 | 
															
																@@ -54,17 +55,25 @@ func pathHandler(w http.ResponseWriter, r *http.Request) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 		return 
															 | 
															
															 | 
															
																 		return 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 	} 
															 | 
															
															 | 
															
																 	} 
															 | 
														
													
												
													
														
															| 
															 | 
															
																  
															 | 
															
															 | 
															
																  
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+	if h := r.Header.Get("Connection"); len(h) > 0 && strings.ToLower(h) == "upgrade" { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+		if h = r.Header.Get("Upgrade"); len(h) > 0 && strings.ToLower(h) == "websocket" { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+			info("Websocket connections not supported yet. Headers: %+v", r.Header) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+		} 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+	} 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 	if r.Method == "GET" { 
															 | 
															
															 | 
															
																 	if r.Method == "GET" { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-		log.Printf("%s [GET] Connected", pathID) 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+		info("%s [GET] Connected", pathID) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 		handleGet(pathID, w, r) 
															 | 
															
															 | 
															
																 		handleGet(pathID, w, r) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-	} else { 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-		log.Printf("%s [POST] Connected", pathID) 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+	} else if r.Method == "POST" { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+		info("%s [POST] Connected", pathID) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 		if h := r.Header.Get("X-Pathway"); h == "pubsub" { 
															 | 
															
															 | 
															
																 		if h := r.Header.Get("X-Pathway"); h == "pubsub" { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 			debug("%s [PUBSUB] Upgrade POST to PUBSUB", pathID) 
															 | 
															
															 | 
															
																 			debug("%s [PUBSUB] Upgrade POST to PUBSUB", pathID) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 			handlePubSub(pathID, r) 
															 | 
															
															 | 
															
																 			handlePubSub(pathID, r) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 		} else { 
															 | 
															
															 | 
															
																 		} else { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 			handlePost(pathID, r) 
															 | 
															
															 | 
															
																 			handlePost(pathID, r) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 		} 
															 | 
															
															 | 
															
																 		} 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+	} else { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+		info("Unhandled request type: '%s'", r.Method) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 	} 
															 | 
															
															 | 
															
																 	} 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 } 
															 | 
															
															 | 
															
																 } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																  
															 | 
															
															 | 
															
																  
															 | 
														
													
												
											
												
													
														
															 | 
															
																@@ -78,7 +87,7 @@ func emptyHandler(w http.ResponseWriter, r *http.Request) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 } 
															 | 
															
															 | 
															
																 } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																  
															 | 
															
															 | 
															
																  
															 | 
														
													
												
													
														
															| 
															 | 
															
																 func main() { 
															 | 
															
															 | 
															
																 func main() { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-	log.Printf("pathway version:%s buildtime:%s", version, buildtime) 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+	info("pathway version:%s buildtime:%s", version, buildtime) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																  
															 | 
															
															 | 
															
																  
															 | 
														
													
												
													
														
															| 
															 | 
															
																 	http.HandleFunc("/health", okHandler) 
															 | 
															
															 | 
															
																 	http.HandleFunc("/health", okHandler) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 	http.HandleFunc("/favicon.ico", emptyHandler) 
															 | 
															
															 | 
															
																 	http.HandleFunc("/favicon.ico", emptyHandler) 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@@ -87,12 +96,16 @@ func main() { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																  
															 | 
															
															 | 
															
																  
															 | 
														
													
												
													
														
															| 
															 | 
															
																 	err := http.ListenAndServe(":8080", nil) 
															 | 
															
															 | 
															
																 	err := http.ListenAndServe(":8080", nil) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 	if err != nil { 
															 | 
															
															 | 
															
																 	if err != nil { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-		log.Println(err) 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+		info("%s", err.Error()) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 	} 
															 | 
															
															 | 
															
																 	} 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 } 
															 | 
															
															 | 
															
																 } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																  
															 | 
															
															 | 
															
																  
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+func info(msg string, args ...interface{}) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+	log.Printf("INFO | "+msg, args...) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+} 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 func debug(msg string, args ...interface{}) { 
															 | 
															
															 | 
															
																 func debug(msg string, args ...interface{}) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 	if len(debugging) > 0 { 
															 | 
															
															 | 
															
																 	if len(debugging) > 0 { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-		log.Printf(msg, args...) 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+		log.Printf("DEBUG | "+msg, args...) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 	} 
															 | 
															
															 | 
															
																 	} 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 } 
															 | 
															
															 | 
															
																 } 
															 |