Skip to content

Commit

Permalink
feat: grpc header forwarding (#508)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
potterbm-cb authored Nov 8, 2024
1 parent bad12fa commit dab4a57
Show file tree
Hide file tree
Showing 37 changed files with 421 additions and 456 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
pull_request:

env:
go_version: 1.18
go_version: 1.19
GO111MODULE: on
COVERALLS_TOKEN: ${{ secrets.COVERALLS_TOKEN }}

Expand Down Expand Up @@ -57,15 +57,15 @@ jobs:
- uses: actions/checkout@v3
with:
version: latest
- run: make check-format
- run: make check-format

Check-Gen:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
version: latest
- run: make check-gen
- run: make check-gen

Coverage:
runs-on: ubuntu-latest
Expand All @@ -85,4 +85,3 @@ jobs:
with:
version: latest
- run: make salus

6 changes: 3 additions & 3 deletions asserter/asserter.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package asserter
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path"
"strings"

Expand Down Expand Up @@ -240,7 +240,7 @@ type Configuration struct {
func NewClientWithFile(
filePath string,
) (*Asserter, error) {
content, err := ioutil.ReadFile(path.Clean(filePath))
content, err := os.ReadFile(path.Clean(filePath))
if err != nil {
return nil, fmt.Errorf("failed to read file %s: %w", filePath, err)
}
Expand Down Expand Up @@ -438,7 +438,7 @@ func getValidationConfig(validationFilePath string) (*Validations, error) {
Enabled: false,
}
if validationFilePath != "" {
content, err := ioutil.ReadFile(path.Clean(validationFilePath))
content, err := os.ReadFile(path.Clean(validationFilePath))
if err != nil {
return nil, fmt.Errorf("failed to read file %s: %w", validationFilePath, err)
}
Expand Down
7 changes: 3 additions & 4 deletions asserter/asserter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"os"
"testing"

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

tmpfile, err := ioutil.TempFile("", "test.json")
tmpfile, err := os.CreateTemp("", "test.json")
assert.NoError(t, err)
defer os.Remove(tmpfile.Name())

Expand Down Expand Up @@ -473,7 +472,7 @@ func TestNew(t *testing.T) {
})

t.Run("file not formatted correctly", func(t *testing.T) {
tmpfile, err := ioutil.TempFile("", "test.json")
tmpfile, err := os.CreateTemp("", "test.json")
assert.NoError(t, err)
defer os.Remove(tmpfile.Name())

Expand Down Expand Up @@ -515,7 +514,7 @@ func TestNew(t *testing.T) {
})

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

Expand Down
5 changes: 2 additions & 3 deletions client/api_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
_context "context"
"fmt"
"io"
_ioutil "io/ioutil"
_nethttp "net/http"

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

localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
defer func() {
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
_ = localVarHTTPResponse.Body.Close()
Expand Down Expand Up @@ -193,7 +192,7 @@ func (a *AccountAPIService) AccountCoins(
return nil, nil, fmt.Errorf("failed to call API: %w", err)
}

localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
defer func() {
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
_ = localVarHTTPResponse.Body.Close()
Expand Down
5 changes: 2 additions & 3 deletions client/api_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
_context "context"
"fmt"
"io"
_ioutil "io/ioutil"
_nethttp "net/http"

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

localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
defer func() {
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
_ = localVarHTTPResponse.Body.Close()
Expand Down Expand Up @@ -193,7 +192,7 @@ func (a *BlockAPIService) BlockTransaction(
return nil, nil, fmt.Errorf("failed to call API: %w", err)
}

localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
defer func() {
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
_ = localVarHTTPResponse.Body.Close()
Expand Down
3 changes: 1 addition & 2 deletions client/api_call.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
_context "context"
"fmt"
"io"
_ioutil "io/ioutil"
_nethttp "net/http"

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

localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
defer func() {
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
_ = localVarHTTPResponse.Body.Close()
Expand Down
17 changes: 8 additions & 9 deletions client/api_construction.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
_context "context"
"fmt"
"io"
_ioutil "io/ioutil"
_nethttp "net/http"

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

localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
defer func() {
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
_ = localVarHTTPResponse.Body.Close()
Expand Down Expand Up @@ -176,7 +175,7 @@ func (a *ConstructionAPIService) ConstructionDerive(
return nil, nil, fmt.Errorf("failed to call API: %w", err)
}

localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
defer func() {
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
_ = localVarHTTPResponse.Body.Close()
Expand Down Expand Up @@ -273,7 +272,7 @@ func (a *ConstructionAPIService) ConstructionHash(
return nil, nil, fmt.Errorf("failed to call API: %w", err)
}

localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
defer func() {
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
_ = localVarHTTPResponse.Body.Close()
Expand Down Expand Up @@ -377,7 +376,7 @@ func (a *ConstructionAPIService) ConstructionMetadata(
return nil, nil, fmt.Errorf("failed to call API: %w", err)
}

localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
defer func() {
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
_ = localVarHTTPResponse.Body.Close()
Expand Down Expand Up @@ -475,7 +474,7 @@ func (a *ConstructionAPIService) ConstructionParse(
return nil, nil, fmt.Errorf("failed to call API: %w", err)
}

localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
defer func() {
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
_ = localVarHTTPResponse.Body.Close()
Expand Down Expand Up @@ -578,7 +577,7 @@ func (a *ConstructionAPIService) ConstructionPayloads(
return nil, nil, fmt.Errorf("failed to call API: %w", err)
}

localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
defer func() {
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
_ = localVarHTTPResponse.Body.Close()
Expand Down Expand Up @@ -679,7 +678,7 @@ func (a *ConstructionAPIService) ConstructionPreprocess(
return nil, nil, fmt.Errorf("failed to call API: %w", err)
}

localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
defer func() {
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
_ = localVarHTTPResponse.Body.Close()
Expand Down Expand Up @@ -779,7 +778,7 @@ func (a *ConstructionAPIService) ConstructionSubmit(
return nil, nil, fmt.Errorf("failed to call API: %w", err)
}

localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
defer func() {
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
_ = localVarHTTPResponse.Body.Close()
Expand Down
3 changes: 1 addition & 2 deletions client/api_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
_context "context"
"fmt"
"io"
_ioutil "io/ioutil"
_nethttp "net/http"

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

localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
defer func() {
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
_ = localVarHTTPResponse.Body.Close()
Expand Down
5 changes: 2 additions & 3 deletions client/api_mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
_context "context"
"fmt"
"io"
_ioutil "io/ioutil"
_nethttp "net/http"

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

localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
defer func() {
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
_ = localVarHTTPResponse.Body.Close()
Expand Down Expand Up @@ -179,7 +178,7 @@ func (a *MempoolAPIService) MempoolTransaction(
return nil, nil, fmt.Errorf("failed to call API: %w", err)
}

localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
defer func() {
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
_ = localVarHTTPResponse.Body.Close()
Expand Down
7 changes: 3 additions & 4 deletions client/api_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
_context "context"
"fmt"
"io"
_ioutil "io/ioutil"
_nethttp "net/http"

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

localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
defer func() {
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
_ = localVarHTTPResponse.Body.Close()
Expand Down Expand Up @@ -176,7 +175,7 @@ func (a *NetworkAPIService) NetworkOptions(
return nil, nil, fmt.Errorf("failed to call API: %w", err)
}

localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
defer func() {
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
_ = localVarHTTPResponse.Body.Close()
Expand Down Expand Up @@ -273,7 +272,7 @@ func (a *NetworkAPIService) NetworkStatus(
return nil, nil, fmt.Errorf("failed to call API: %w", err)
}

localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
defer func() {
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
_ = localVarHTTPResponse.Body.Close()
Expand Down
3 changes: 1 addition & 2 deletions client/api_search.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
_context "context"
"fmt"
"io"
_ioutil "io/ioutil"
_nethttp "net/http"

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

localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
defer func() {
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
_ = localVarHTTPResponse.Body.Close()
Expand Down
Loading

0 comments on commit dab4a57

Please sign in to comment.