Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: do not close empty request body #196

Merged
merged 1 commit into from
Mar 19, 2024
Merged
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: 6 additions & 5 deletions internal/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import (
"github.com/blinklabs-io/tx-submit-api/internal/config"
"github.com/blinklabs-io/tx-submit-api/internal/logging"
"github.com/blinklabs-io/tx-submit-api/submit"

)

// @title tx-submit-api
Expand All @@ -45,8 +44,8 @@ import (
// @contact.url https://blinklabs.io
// @contact.email [email protected]

// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
func Start(cfg *config.Config) error {
// Disable gin debug and color output
gin.SetMode(gin.ReleaseMode)
Expand Down Expand Up @@ -256,8 +255,10 @@ func handleSubmitTx(c *gin.Context) {
return
}
// Close request body after read
if err := c.Request.Body.Close(); err != nil {
logger.Errorf("failed to close request body: %s", err)
if c.Request.Body != nil {
if err := c.Request.Body.Close(); err != nil {
logger.Errorf("failed to close request body: %s", err)
}
}
// Send TX
errorChan := make(chan error)
Expand Down