feat(RuCaptcha): add post form support
All checks were successful
release-tag / release (push) Successful in 1m58s
All checks were successful
release-tag / release (push) Successful in 1m58s
This commit is contained in:
parent
8f3d67c648
commit
a9cf77ca52
@ -37,6 +37,27 @@ type ruCaptchaResponse interface{ text() string }
|
||||
func (a *ruCaptchaApi) wrap(handler func(url.Values) ruCaptchaResponse) func(http.ResponseWriter, *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
query := r.URL.Query()
|
||||
if r.Method != "GET" {
|
||||
var err error
|
||||
switch strings.ToLower(r.Header.Get("Content-Type")) {
|
||||
case "application/x-www-form-urlencoded":
|
||||
err = r.ParseForm()
|
||||
case "multipart/form-data":
|
||||
err = r.ParseMultipartForm(0)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
// merge form with url params
|
||||
for key, values := range r.Form {
|
||||
if _, ok := query[key]; ok {
|
||||
query[key] = append(query[key], values...)
|
||||
} else {
|
||||
query[key] = values
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
useJson := false
|
||||
if val := query.Get("json"); val != "" && val != "0" {
|
||||
useJson = true
|
||||
|
Loading…
x
Reference in New Issue
Block a user