From c0f0414ff8a058f7d3d2d10af9a2ae2b8e3a46a2 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Tue, 9 Sep 2025 17:05:05 -0500 Subject: [PATCH] smarter variable name. predicts a logpb --- httpRequest.proto | 2 +- startHTTP.go | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 startHTTP.go 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 +}