Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions client/api_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package client
import (
_context "context"
"fmt"
"io"
_ioutil "io/ioutil"
_nethttp "net/http"

Expand Down Expand Up @@ -87,7 +88,10 @@ func (a *AccountAPIService) AccountBalance(
}

localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
defer localVarHTTPResponse.Body.Close()
defer func() {
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
_ = localVarHTTPResponse.Body.Close()
}()
if err != nil {
return nil, nil, fmt.Errorf("failed to read response: %w", err)
}
Expand Down Expand Up @@ -190,7 +194,10 @@ func (a *AccountAPIService) AccountCoins(
}

localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
defer localVarHTTPResponse.Body.Close()
defer func() {
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
_ = localVarHTTPResponse.Body.Close()
}()
if err != nil {
return nil, nil, fmt.Errorf("failed to read response: %w", err)
}
Expand Down
11 changes: 9 additions & 2 deletions client/api_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package client
import (
_context "context"
"fmt"
"io"
_ioutil "io/ioutil"
_nethttp "net/http"

Expand Down Expand Up @@ -84,7 +85,10 @@ func (a *BlockAPIService) Block(
}

localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
defer localVarHTTPResponse.Body.Close()
defer func() {
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
_ = localVarHTTPResponse.Body.Close()
}()
if err != nil {
return nil, nil, fmt.Errorf("failed to read response: %w", err)
}
Expand Down Expand Up @@ -190,7 +194,10 @@ func (a *BlockAPIService) BlockTransaction(
}

localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
defer localVarHTTPResponse.Body.Close()
defer func() {
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
_ = localVarHTTPResponse.Body.Close()
}()
if err != nil {
return nil, nil, fmt.Errorf("failed to read response: %w", err)
}
Expand Down
6 changes: 5 additions & 1 deletion client/api_call.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package client
import (
_context "context"
"fmt"
"io"
_ioutil "io/ioutil"
_nethttp "net/http"

Expand Down Expand Up @@ -87,7 +88,10 @@ func (a *CallAPIService) Call(
}

localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
defer localVarHTTPResponse.Body.Close()
defer func() {
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
_ = localVarHTTPResponse.Body.Close()
}()
if err != nil {
return nil, nil, fmt.Errorf("failed to read response: %w", err)
}
Expand Down
41 changes: 33 additions & 8 deletions client/api_construction.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package client
import (
_context "context"
"fmt"
"io"
_ioutil "io/ioutil"
_nethttp "net/http"

Expand Down Expand Up @@ -79,7 +80,10 @@ func (a *ConstructionAPIService) ConstructionCombine(
}

localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
defer localVarHTTPResponse.Body.Close()
defer func() {
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
_ = localVarHTTPResponse.Body.Close()
}()
if err != nil {
return nil, nil, fmt.Errorf("failed to read response: %w", err)
}
Expand Down Expand Up @@ -173,7 +177,10 @@ func (a *ConstructionAPIService) ConstructionDerive(
}

localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
defer localVarHTTPResponse.Body.Close()
defer func() {
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
_ = localVarHTTPResponse.Body.Close()
}()
if err != nil {
return nil, nil, fmt.Errorf("failed to read response: %w", err)
}
Expand Down Expand Up @@ -267,7 +274,10 @@ func (a *ConstructionAPIService) ConstructionHash(
}

localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
defer localVarHTTPResponse.Body.Close()
defer func() {
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
_ = localVarHTTPResponse.Body.Close()
}()
if err != nil {
return nil, nil, fmt.Errorf("failed to read response: %w", err)
}
Expand Down Expand Up @@ -368,7 +378,10 @@ func (a *ConstructionAPIService) ConstructionMetadata(
}

localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
defer localVarHTTPResponse.Body.Close()
defer func() {
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
_ = localVarHTTPResponse.Body.Close()
}()
if err != nil {
return nil, nil, fmt.Errorf("failed to read response: %w", err)
}
Expand Down Expand Up @@ -463,7 +476,10 @@ func (a *ConstructionAPIService) ConstructionParse(
}

localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
defer localVarHTTPResponse.Body.Close()
defer func() {
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
_ = localVarHTTPResponse.Body.Close()
}()
if err != nil {
return nil, nil, fmt.Errorf("failed to read response: %w", err)
}
Expand Down Expand Up @@ -563,7 +579,10 @@ func (a *ConstructionAPIService) ConstructionPayloads(
}

localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
defer localVarHTTPResponse.Body.Close()
defer func() {
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
_ = localVarHTTPResponse.Body.Close()
}()
if err != nil {
return nil, nil, fmt.Errorf("failed to read response: %w", err)
}
Expand Down Expand Up @@ -661,7 +680,10 @@ func (a *ConstructionAPIService) ConstructionPreprocess(
}

localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
defer localVarHTTPResponse.Body.Close()
defer func() {
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
_ = localVarHTTPResponse.Body.Close()
}()
if err != nil {
return nil, nil, fmt.Errorf("failed to read response: %w", err)
}
Expand Down Expand Up @@ -758,7 +780,10 @@ func (a *ConstructionAPIService) ConstructionSubmit(
}

localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
defer localVarHTTPResponse.Body.Close()
defer func() {
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
_ = localVarHTTPResponse.Body.Close()
}()
if err != nil {
return nil, nil, fmt.Errorf("failed to read response: %w", err)
}
Expand Down
6 changes: 5 additions & 1 deletion client/api_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package client
import (
_context "context"
"fmt"
"io"
_ioutil "io/ioutil"
_nethttp "net/http"

Expand Down Expand Up @@ -82,7 +83,10 @@ func (a *EventsAPIService) EventsBlocks(
}

localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
defer localVarHTTPResponse.Body.Close()
defer func() {
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
_ = localVarHTTPResponse.Body.Close()
}()
if err != nil {
return nil, nil, fmt.Errorf("failed to read response: %w", err)
}
Expand Down
11 changes: 9 additions & 2 deletions client/api_mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package client
import (
_context "context"
"fmt"
"io"
_ioutil "io/ioutil"
_nethttp "net/http"

Expand Down Expand Up @@ -77,7 +78,10 @@ func (a *MempoolAPIService) Mempool(
}

localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
defer localVarHTTPResponse.Body.Close()
defer func() {
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
_ = localVarHTTPResponse.Body.Close()
}()
if err != nil {
return nil, nil, fmt.Errorf("failed to read response: %w", err)
}
Expand Down Expand Up @@ -176,7 +180,10 @@ func (a *MempoolAPIService) MempoolTransaction(
}

localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
defer localVarHTTPResponse.Body.Close()
defer func() {
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
_ = localVarHTTPResponse.Body.Close()
}()
if err != nil {
return nil, nil, fmt.Errorf("failed to read response: %w", err)
}
Expand Down
16 changes: 13 additions & 3 deletions client/api_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package client
import (
_context "context"
"fmt"
"io"
_ioutil "io/ioutil"
_nethttp "net/http"

Expand Down Expand Up @@ -77,7 +78,10 @@ func (a *NetworkAPIService) NetworkList(
}

localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
defer localVarHTTPResponse.Body.Close()
defer func() {
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
_ = localVarHTTPResponse.Body.Close()
}()
if err != nil {
return nil, nil, fmt.Errorf("failed to read response: %w", err)
}
Expand Down Expand Up @@ -173,7 +177,10 @@ func (a *NetworkAPIService) NetworkOptions(
}

localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
defer localVarHTTPResponse.Body.Close()
defer func() {
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
_ = localVarHTTPResponse.Body.Close()
}()
if err != nil {
return nil, nil, fmt.Errorf("failed to read response: %w", err)
}
Expand Down Expand Up @@ -267,7 +274,10 @@ func (a *NetworkAPIService) NetworkStatus(
}

localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
defer localVarHTTPResponse.Body.Close()
defer func() {
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
_ = localVarHTTPResponse.Body.Close()
}()
if err != nil {
return nil, nil, fmt.Errorf("failed to read response: %w", err)
}
Expand Down
6 changes: 5 additions & 1 deletion client/api_search.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package client
import (
_context "context"
"fmt"
"io"
_ioutil "io/ioutil"
_nethttp "net/http"

Expand Down Expand Up @@ -82,7 +83,10 @@ func (a *SearchAPIService) SearchTransactions(
}

localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
defer localVarHTTPResponse.Body.Close()
defer func() {
_, _ = io.Copy(io.Discard, localVarHTTPResponse.Body)
_ = localVarHTTPResponse.Body.Close()
}()
if err != nil {
return nil, nil, fmt.Errorf("failed to read response: %w", err)
}
Expand Down
6 changes: 5 additions & 1 deletion constructor/worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"context"
"errors"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
Expand Down Expand Up @@ -871,7 +872,10 @@ func HTTPRequestWorker(rawInput string) (string, error) {
if err != nil {
return "", fmt.Errorf("failed to send request: %w", err)
}
defer resp.Body.Close()
defer func() {
_, _ = io.Copy(io.Discard, resp.Body)
_ = resp.Body.Close()
}()

body, err := ioutil.ReadAll(resp.Body)
if err != nil {
Expand Down
12 changes: 11 additions & 1 deletion examples/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"fmt"
"log"
"net/http"
"time"

"github.com/coinbase/rosetta-sdk-go/asserter"
"github.com/coinbase/rosetta-sdk-go/examples/server/services"
Expand Down Expand Up @@ -76,5 +77,14 @@ func main() {
loggedRouter := server.LoggerMiddleware(router)
corsRouter := server.CorsMiddleware(loggedRouter)
log.Printf("Listening on port %d\n", serverPort)
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", serverPort), corsRouter))

srv := &http.Server{
Addr: fmt.Sprintf(":%d", serverPort),
Handler: corsRouter,
ReadTimeout: 5 * time.Second,
WriteTimeout: 10 * time.Second,
IdleTimeout: 15 * time.Second,
}

log.Fatal(srv.ListenAndServe())
}
Loading