Skip to content

Commit 0238da3

Browse files
Add immutable methods withGrpcCallOption, withMetadata to grpc.web.request, response
1 parent 6f5ecb0 commit 0238da3

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

javascript/net/grpc/web/request.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,21 @@ class Request {
4040
* @return {!CallOptions|undefined}
4141
*/
4242
getCallOptions() {}
43+
44+
/**
45+
* @param {string} key
46+
* @param {string} value
47+
* @return {!Request<REQUEST, RESPONSE>}
48+
*/
49+
withMetadata(key, value) {}
50+
51+
/**
52+
* @param {string} name
53+
* @param {VALUE} value
54+
* @template VALUE
55+
* @return {!Request<REQUEST, RESPONSE>}
56+
*/
57+
withGrpcCallOption(name, value) {}
4358
}
4459

4560
exports = Request;

javascript/net/grpc/web/requestinternal.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,22 @@ class RequestInternal {
7373
getCallOptions() {
7474
return this.callOptions_;
7575
}
76+
77+
/**
78+
* @override
79+
*/
80+
withMetadata(key, value) {
81+
this.metadata_[key] = value;
82+
return this;
83+
}
84+
85+
/**
86+
* @override
87+
*/
88+
withGrpcCallOption(name, value) {
89+
this.callOptions_.setOption(name, value);
90+
return this;
91+
}
7692
}
7793

7894
exports = RequestInternal;

0 commit comments

Comments
 (0)