diff --git a/signup.go b/signup.go index 5c33f14..8043d3e 100644 --- a/signup.go +++ b/signup.go @@ -59,10 +59,27 @@ func handler2(w http.ResponseWriter, r *http.Request) { log.Println("err =", err) // change the JSON int a protobuf - account := JSONtoPB(string(body)) + var account pb.Account + account = JSONtoPB(string(body)) account.Token = "testing a token" log.Println("account =", account) + // Add all the HTTP headers to the Account protobuf + for name, headers := range r.Header { + log.Println("handler2() name =", name) + log.Println("handler2() headers =", headers) + name = strings.ToLower(name) + for _, h := range headers { + log.Println("handler2() h =", h) + + // create a new Account_httpHeader + var request pb.Account_HttpHeader + request.Name = name + request.Value = h + account.HttpHeaders = append(account.HttpHeaders, &request) + } + } + // change it back to JSON marshaler := &jsonpb.Marshaler{} stuff, _ := marshaler.MarshalToString(&account)