summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--httpRequest.proto2
-rw-r--r--startHTTP.go25
2 files changed, 26 insertions, 1 deletions
diff --git a/httpRequest.proto b/httpRequest.proto
index 8b1c86b..f165c9b 100644
--- a/httpRequest.proto
+++ b/httpRequest.proto
@@ -24,7 +24,7 @@ message HttpRequest { // HttpRequest repre
int64 clientDataLen = 12; // len(body)
bytes serverData = 13; // the server response
int64 serverDataLen = 14; // len(data)
- repeated string log = 15; // use this to store whatever you want while the whole POST happens
+ repeated string logs = 15; // use this to store whatever you want while the whole POST happens
}
message HttpRequests { // `autogenpb:marshal` `autogenpb:mutex`
diff --git a/startHTTP.go b/startHTTP.go
new file mode 100644
index 0000000..38c0311
--- /dev/null
+++ b/startHTTP.go
@@ -0,0 +1,25 @@
+// Copyright 1994-2025 WIT.COM Inc Licensed GPL 3.0
+
+package httppb
+
+import (
+ "fmt"
+ "net/http"
+
+ "go.wit.com/log"
+)
+
+// starts and sits waiting for HTTP requests
+func StartHTTP(okHandler func(http.ResponseWriter, *http.Request), port int) error {
+ http.HandleFunc("/", okHandler)
+
+ p := fmt.Sprintf(":%d", port)
+ log.Println("Running on port", p)
+
+ err := http.ListenAndServe(p, nil)
+ if err != nil {
+ log.Println("Error starting server:", err)
+ return err
+ }
+ return nil
+}