write out the protobuf
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
aff660822e
commit
4fbfc3dde7
19
signup.go
19
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)
|
||||
|
|
Loading…
Reference in New Issue