Skip to content

Commit

Permalink
chore(faucet): compliency gno/faucet and gnoweb
Browse files Browse the repository at this point in the history
  • Loading branch information
albttx committed Dec 16, 2023
1 parent 14e5674 commit 9ad369f
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,37 @@ var errInvalidBeneficiary = errors.New("invalid beneficiary address")

// defaultHTTPHandler is the default faucet transfer handler
func (f *Faucet) defaultHTTPHandler(w http.ResponseWriter, r *http.Request) {
err := r.ParseForm()
if err != nil {
http.Error(w, "invalid request body", http.StatusBadRequest)
return

Check failure on line 27 in handler.go

View workflow job for this annotation

GitHub Actions / Go Linter / lint

return with no blank line before (nlreturn)
}

// Load the requests
requestBody, readErr := io.ReadAll(r.Body)
if readErr != nil {
http.Error(w, "unable to read request", http.StatusBadRequest)

return

Check failure on line 34 in handler.go

View workflow job for this annotation

GitHub Actions / Go Linter / lint

return with no blank line before (nlreturn)
}

// Extract the requests
requests, err := extractRequests(requestBody)
if err != nil {
http.Error(
w,
"invalid request body",
http.StatusBadRequest,
)
var requests Requests

return
if to := r.FormValue("toaddr"); to != "" {
requests = Requests{
{To: to},
}
} else {
// Extract the requests
requests, err = extractRequests(requestBody)
if err != nil {
http.Error(
w,
"invalid request body",
http.StatusBadRequest,
)

return
}
}

// Handle the requests
Expand Down

0 comments on commit 9ad369f

Please sign in to comment.