Skip to content

Commit dab4a57

Browse files
authored
feat: grpc header forwarding (#508)
* add header forwarding for grpc * proper header handling for grpc metadata * Add outgoing header forwarding * revert request context changes to controller * update go to 1.19 * fix server templates * remove ioutil * make gen * remove extra context import * fix routers.go
1 parent bad12fa commit dab4a57

37 files changed

+421
-456
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
pull_request:
88

99
env:
10-
go_version: 1.18
10+
go_version: 1.19
1111
GO111MODULE: on
1212
COVERALLS_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
1313

@@ -57,15 +57,15 @@ jobs:
5757
- uses: actions/checkout@v3
5858
with:
5959
version: latest
60-
- run: make check-format
61-
60+
- run: make check-format
61+
6262
Check-Gen:
6363
runs-on: ubuntu-latest
6464
steps:
6565
- uses: actions/checkout@v3
6666
with:
6767
version: latest
68-
- run: make check-gen
68+
- run: make check-gen
6969

7070
Coverage:
7171
runs-on: ubuntu-latest
@@ -85,4 +85,3 @@ jobs:
8585
with:
8686
version: latest
8787
- run: make salus
88-

asserter/asserter.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ package asserter
1717
import (
1818
"encoding/json"
1919
"fmt"
20-
"io/ioutil"
20+
"os"
2121
"path"
2222
"strings"
2323

@@ -240,7 +240,7 @@ type Configuration struct {
240240
func NewClientWithFile(
241241
filePath string,
242242
) (*Asserter, error) {
243-
content, err := ioutil.ReadFile(path.Clean(filePath))
243+
content, err := os.ReadFile(path.Clean(filePath))
244244
if err != nil {
245245
return nil, fmt.Errorf("failed to read file %s: %w", filePath, err)
246246
}
@@ -438,7 +438,7 @@ func getValidationConfig(validationFilePath string) (*Validations, error) {
438438
Enabled: false,
439439
}
440440
if validationFilePath != "" {
441-
content, err := ioutil.ReadFile(path.Clean(validationFilePath))
441+
content, err := os.ReadFile(path.Clean(validationFilePath))
442442
if err != nil {
443443
return nil, fmt.Errorf("failed to read file %s: %w", validationFilePath, err)
444444
}

asserter/asserter_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"encoding/json"
1919
"errors"
2020
"fmt"
21-
"io/ioutil"
2221
"os"
2322
"testing"
2423

@@ -410,7 +409,7 @@ func TestNew(t *testing.T) {
410409
fileConfig.AllowedTimestampStartIndex = fileConfig.GenesisBlockIdentifier.Index + 1
411410
}
412411

413-
tmpfile, err := ioutil.TempFile("", "test.json")
412+
tmpfile, err := os.CreateTemp("", "test.json")
414413
assert.NoError(t, err)
415414
defer os.Remove(tmpfile.Name())
416415

@@ -473,7 +472,7 @@ func TestNew(t *testing.T) {
473472
})
474473

475474
t.Run("file not formatted correctly", func(t *testing.T) {
476-
tmpfile, err := ioutil.TempFile("", "test.json")
475+
tmpfile, err := os.CreateTemp("", "test.json")
477476
assert.NoError(t, err)
478477
defer os.Remove(tmpfile.Name())
479478

@@ -515,7 +514,7 @@ func TestNew(t *testing.T) {
515514
})
516515

517516
t.Run("wrong format of validation file", func(t *testing.T) {
518-
tmpfile, err := ioutil.TempFile("", "test.json")
517+
tmpfile, err := os.CreateTemp("", "test.json")
519518
assert.NoError(t, err)
520519
defer os.Remove(tmpfile.Name())
521520

client/api_account.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
_context "context"
2121
"fmt"
2222
"io"
23-
_ioutil "io/ioutil"
2423
_nethttp "net/http"
2524

2625
"github.com/coinbase/rosetta-sdk-go/types"
@@ -87,7 +86,7 @@ func (a *AccountAPIService) AccountBalance(
8786
return nil, nil, fmt.Errorf("failed to call API: %w", err)
8887
}
8988

90-
localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
89+
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
9190
defer func() {
9291
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
9392
_ = localVarHTTPResponse.Body.Close()
@@ -193,7 +192,7 @@ func (a *AccountAPIService) AccountCoins(
193192
return nil, nil, fmt.Errorf("failed to call API: %w", err)
194193
}
195194

196-
localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
195+
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
197196
defer func() {
198197
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
199198
_ = localVarHTTPResponse.Body.Close()

client/api_block.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
_context "context"
2121
"fmt"
2222
"io"
23-
_ioutil "io/ioutil"
2423
_nethttp "net/http"
2524

2625
"github.com/coinbase/rosetta-sdk-go/types"
@@ -84,7 +83,7 @@ func (a *BlockAPIService) Block(
8483
return nil, nil, fmt.Errorf("failed to call API: %w", err)
8584
}
8685

87-
localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
86+
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
8887
defer func() {
8988
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
9089
_ = localVarHTTPResponse.Body.Close()
@@ -193,7 +192,7 @@ func (a *BlockAPIService) BlockTransaction(
193192
return nil, nil, fmt.Errorf("failed to call API: %w", err)
194193
}
195194

196-
localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
195+
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
197196
defer func() {
198197
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
199198
_ = localVarHTTPResponse.Body.Close()

client/api_call.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
_context "context"
2121
"fmt"
2222
"io"
23-
_ioutil "io/ioutil"
2423
_nethttp "net/http"
2524

2625
"github.com/coinbase/rosetta-sdk-go/types"
@@ -87,7 +86,7 @@ func (a *CallAPIService) Call(
8786
return nil, nil, fmt.Errorf("failed to call API: %w", err)
8887
}
8988

90-
localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
89+
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
9190
defer func() {
9291
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
9392
_ = localVarHTTPResponse.Body.Close()

client/api_construction.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
_context "context"
2121
"fmt"
2222
"io"
23-
_ioutil "io/ioutil"
2423
_nethttp "net/http"
2524

2625
"github.com/coinbase/rosetta-sdk-go/types"
@@ -79,7 +78,7 @@ func (a *ConstructionAPIService) ConstructionCombine(
7978
return nil, nil, fmt.Errorf("failed to call API: %w", err)
8079
}
8180

82-
localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
81+
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
8382
defer func() {
8483
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
8584
_ = localVarHTTPResponse.Body.Close()
@@ -176,7 +175,7 @@ func (a *ConstructionAPIService) ConstructionDerive(
176175
return nil, nil, fmt.Errorf("failed to call API: %w", err)
177176
}
178177

179-
localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
178+
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
180179
defer func() {
181180
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
182181
_ = localVarHTTPResponse.Body.Close()
@@ -273,7 +272,7 @@ func (a *ConstructionAPIService) ConstructionHash(
273272
return nil, nil, fmt.Errorf("failed to call API: %w", err)
274273
}
275274

276-
localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
275+
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
277276
defer func() {
278277
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
279278
_ = localVarHTTPResponse.Body.Close()
@@ -377,7 +376,7 @@ func (a *ConstructionAPIService) ConstructionMetadata(
377376
return nil, nil, fmt.Errorf("failed to call API: %w", err)
378377
}
379378

380-
localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
379+
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
381380
defer func() {
382381
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
383382
_ = localVarHTTPResponse.Body.Close()
@@ -475,7 +474,7 @@ func (a *ConstructionAPIService) ConstructionParse(
475474
return nil, nil, fmt.Errorf("failed to call API: %w", err)
476475
}
477476

478-
localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
477+
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
479478
defer func() {
480479
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
481480
_ = localVarHTTPResponse.Body.Close()
@@ -578,7 +577,7 @@ func (a *ConstructionAPIService) ConstructionPayloads(
578577
return nil, nil, fmt.Errorf("failed to call API: %w", err)
579578
}
580579

581-
localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
580+
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
582581
defer func() {
583582
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
584583
_ = localVarHTTPResponse.Body.Close()
@@ -679,7 +678,7 @@ func (a *ConstructionAPIService) ConstructionPreprocess(
679678
return nil, nil, fmt.Errorf("failed to call API: %w", err)
680679
}
681680

682-
localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
681+
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
683682
defer func() {
684683
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
685684
_ = localVarHTTPResponse.Body.Close()
@@ -779,7 +778,7 @@ func (a *ConstructionAPIService) ConstructionSubmit(
779778
return nil, nil, fmt.Errorf("failed to call API: %w", err)
780779
}
781780

782-
localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
781+
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
783782
defer func() {
784783
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
785784
_ = localVarHTTPResponse.Body.Close()

client/api_events.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
_context "context"
2121
"fmt"
2222
"io"
23-
_ioutil "io/ioutil"
2423
_nethttp "net/http"
2524

2625
"github.com/coinbase/rosetta-sdk-go/types"
@@ -82,7 +81,7 @@ func (a *EventsAPIService) EventsBlocks(
8281
return nil, nil, fmt.Errorf("failed to call API: %w", err)
8382
}
8483

85-
localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
84+
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
8685
defer func() {
8786
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
8887
_ = localVarHTTPResponse.Body.Close()

client/api_mempool.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
_context "context"
2121
"fmt"
2222
"io"
23-
_ioutil "io/ioutil"
2423
_nethttp "net/http"
2524

2625
"github.com/coinbase/rosetta-sdk-go/types"
@@ -77,7 +76,7 @@ func (a *MempoolAPIService) Mempool(
7776
return nil, nil, fmt.Errorf("failed to call API: %w", err)
7877
}
7978

80-
localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
79+
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
8180
defer func() {
8281
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
8382
_ = localVarHTTPResponse.Body.Close()
@@ -179,7 +178,7 @@ func (a *MempoolAPIService) MempoolTransaction(
179178
return nil, nil, fmt.Errorf("failed to call API: %w", err)
180179
}
181180

182-
localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
181+
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
183182
defer func() {
184183
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
185184
_ = localVarHTTPResponse.Body.Close()

client/api_network.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
_context "context"
2121
"fmt"
2222
"io"
23-
_ioutil "io/ioutil"
2423
_nethttp "net/http"
2524

2625
"github.com/coinbase/rosetta-sdk-go/types"
@@ -77,7 +76,7 @@ func (a *NetworkAPIService) NetworkList(
7776
return nil, nil, fmt.Errorf("failed to call API: %w", err)
7877
}
7978

80-
localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
79+
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
8180
defer func() {
8281
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
8382
_ = localVarHTTPResponse.Body.Close()
@@ -176,7 +175,7 @@ func (a *NetworkAPIService) NetworkOptions(
176175
return nil, nil, fmt.Errorf("failed to call API: %w", err)
177176
}
178177

179-
localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
178+
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
180179
defer func() {
181180
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
182181
_ = localVarHTTPResponse.Body.Close()
@@ -273,7 +272,7 @@ func (a *NetworkAPIService) NetworkStatus(
273272
return nil, nil, fmt.Errorf("failed to call API: %w", err)
274273
}
275274

276-
localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
275+
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
277276
defer func() {
278277
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
279278
_ = localVarHTTPResponse.Body.Close()

client/api_search.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
_context "context"
2121
"fmt"
2222
"io"
23-
_ioutil "io/ioutil"
2423
_nethttp "net/http"
2524

2625
"github.com/coinbase/rosetta-sdk-go/types"
@@ -82,7 +81,7 @@ func (a *SearchAPIService) SearchTransactions(
8281
return nil, nil, fmt.Errorf("failed to call API: %w", err)
8382
}
8483

85-
localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
84+
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
8685
defer func() {
8786
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
8887
_ = localVarHTTPResponse.Body.Close()

0 commit comments

Comments
 (0)