change the names from the http standards
I'll probably regret this and if anyone ever sees this and they actually use it, some people will probably complain. so: sorry It's not like HTTP isn't really well documented these days :) anyway, the *Addr fields are, I think, really really old kinda dumb names that were made to be super unique and ackward like RemoteAddr or whatever. Back then, having 'IP' would have been a major problem and PITA and super confusing. So I think everyone (I want to say 'we' but I don't know if I had anything to do with RemoteAddr. I think I did add the Apache guys to add SERVER_NAME support. Before that I don't think apache could respond to mosaic as 2 different hostnames. My memory could be incorrect.) named some of these things in ways that don't make sense in a protobuf like this where it should simply be IP
This commit is contained in:
parent
4b78407d3f
commit
aef7b966ff
|
@ -8,11 +8,11 @@ import "google/protobuf/timestamp.proto"; // Import the well-known type for Time
|
||||||
|
|
||||||
message HttpRequest { // HttpRequest represents the essential fields of an incoming HTTP request.
|
message HttpRequest { // HttpRequest represents the essential fields of an incoming HTTP request.
|
||||||
string method = 1; // The request method, e.g., "GET", "POST".
|
string method = 1; // The request method, e.g., "GET", "POST".
|
||||||
string url = 2; // The full URL of the request, including scheme, host, path, and query string.
|
string URL = 2; // The full URL of the request, including scheme, host, path, and query string.
|
||||||
string route = 3; // just the route: "/add/" or "/find/"
|
string route = 3; // just the route: "/add/" or "/find/"
|
||||||
string proto = 4; // The protocol version, e.g., "HTTP/1.1", "HTTP/2.0".
|
string proto = 4; // The protocol version, e.g., "HTTP/1.1", "HTTP/2.0".
|
||||||
map<string, string> headers = 5; // The map of request headers. Header names are case-insensitive,
|
map<string, string> headers = 5; // The map of request headers. Header names are case-insensitive,
|
||||||
string remoteAddr = 6; // The remote IP address of the client, after resolving proxies.
|
string IP = 6; // The remote IP address of the client, after resolving proxies.
|
||||||
string host = 7; // The host on which the URL is sought (www.wit.com)
|
string host = 7; // The host on which the URL is sought (www.wit.com)
|
||||||
string hostname = 8; // The hostname of the client if passed from the client (mylaptop.fun.me)
|
string hostname = 8; // The hostname of the client if passed from the client (mylaptop.fun.me)
|
||||||
bytes body = 9; // The request body as raw bytes.
|
bytes body = 9; // The request body as raw bytes.
|
||||||
|
|
16
reqToPB.go
16
reqToPB.go
|
@ -58,14 +58,14 @@ func ReqToPB(r *http.Request) (*HttpRequest, error) {
|
||||||
// log.Info("TRYING TO MARSHAL bytes:", len(msg), err)
|
// log.Info("TRYING TO MARSHAL bytes:", len(msg), err)
|
||||||
|
|
||||||
pb := &HttpRequest{
|
pb := &HttpRequest{
|
||||||
Method: r.Method,
|
Method: r.Method,
|
||||||
Url: r.URL.String(),
|
URL: r.URL.String(),
|
||||||
Proto: r.Proto,
|
Proto: r.Proto,
|
||||||
Headers: headers,
|
Headers: headers,
|
||||||
RemoteAddr: getClientIP(r),
|
IP: getClientIP(r),
|
||||||
Host: r.Host,
|
Host: r.Host,
|
||||||
Body: msg,
|
Body: msg,
|
||||||
Hostname: r.Header.Get("hostname"),
|
Hostname: r.Header.Get("hostname"),
|
||||||
}
|
}
|
||||||
pb.Route = cleanURL(r.URL.Path)
|
pb.Route = cleanURL(r.URL.Path)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue