-
Notifications
You must be signed in to change notification settings - Fork 4
chore(faucet): compliency gno/faucet and gnoweb #8
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,13 @@ 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 | ||
} | ||
|
||
// Load the requests | ||
requestBody, readErr := io.ReadAll(r.Body) | ||
if readErr != nil { | ||
|
@@ -29,16 +36,24 @@ func (f *Faucet) defaultHTTPHandler(w http.ResponseWriter, r *http.Request) { | |
return | ||
} | ||
|
||
// 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}, | ||
} | ||
Comment on lines
+41
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not like the fact we are modelling the behavior of a generic TM2 faucet based on We are deprecating the old gno faucet anyways, so might as well make the change now. I propose we take one of these routes:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 100% ok with this, i just choose a quicker solution for having a fix to work with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. but the "form" system is an easier system for the way we're using gno/templating html |
||
} else { | ||
// Extract the requests | ||
requests, err = extractRequests(requestBody) | ||
if err != nil { | ||
http.Error( | ||
w, | ||
"invalid request body", | ||
http.StatusBadRequest, | ||
) | ||
|
||
return | ||
} | ||
} | ||
|
||
// Handle the requests | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: you can inline this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't put it like that to avoid redefine
err
lower, but i'm fine for adding avar err error
:)