Skip to content

Commit eb2f808

Browse files
author
Jon Bernard
committed
use protobuf ListValue for response headers
1 parent eb36e57 commit eb2f808

File tree

4 files changed

+67
-57
lines changed

4 files changed

+67
-57
lines changed

ldk/go/examples/network/loop/loop.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package loop
33
import (
44
"context"
55
"encoding/json"
6-
"net/http"
76
"time"
87

98
ldk "github.com/open-olive/loop-development-kit/ldk/go"
@@ -84,15 +83,9 @@ func (c *Loop) LoopStart(sidekick ldk.Sidekick) error {
8483
}
8584

8685
if response.ResponseCode == 200 {
87-
var headers http.Header
8886
var data apiResponse
8987

90-
if err := json.Unmarshal(response.Headers, &headers); err != nil {
91-
c.logger.Error("Error unmarshaling response headers", err)
92-
return err
93-
}
94-
95-
c.logger.Info("Response headers", headers)
88+
c.logger.Info("Response headers", response.Headers)
9689

9790
if err := json.Unmarshal(response.Data, &data); err != nil {
9891
c.logger.Error("Error unmarshaling response payload", err)

ldk/go/networkClient.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55

66
"github.com/open-olive/loop-development-kit/ldk/go/proto"
7+
structpb "google.golang.org/protobuf/types/known/structpb"
78
)
89

910
// NetworkClient is the client used by the NetworkService
@@ -16,7 +17,7 @@ type NetworkClient struct {
1617
type HTTPResponse struct {
1718
ResponseCode int
1819
Data []byte
19-
Headers []byte
20+
Headers map[string]*structpb.ListValue
2021
}
2122

2223
// HTTPRequest is the structure received from HttpRequest

ldk/go/proto/network.pb.go

Lines changed: 62 additions & 47 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/network.proto

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ syntax = "proto3";
22
package proto;
33
option go_package = ".;proto";
44

5+
import "google/protobuf/struct.proto";
56
import "session.proto";
67

78
service Network {
@@ -19,5 +20,5 @@ message HTTPRequestMsg {
1920
message HTTPResponseMsg {
2021
uint32 responseCode = 1;
2122
bytes data = 2;
22-
bytes headers = 3;
23+
map <string, google.protobuf.ListValue> headers = 3;
2324
}

0 commit comments

Comments
 (0)