Merge d76523415c2e8e650fdd56f5ddc4fa888a7f1ba5 into aefae309a4fc197ce5d57cd8391562b6d2a63a95

This commit is contained in:
Zhang 2022-11-07 08:02:22 +09:00 committed by GitHub
commit 2ea1e90107
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View File

@ -558,6 +558,13 @@ func (c *Context) GetPostFormMap(key string) (map[string]string, bool) {
return c.get(c.formCache, key) return c.get(c.formCache, key)
} }
// GetPostFormData returns c.formCache, which cached PostForm contains the parsed form data from POST, PATCH,
// or PUT body parameters.
func (c *Context) GetPostFormData() url.Values {
c.initFormCache()
return c.formCache
}
// get is an internal method and returns a map which satisfy conditions. // get is an internal method and returns a map which satisfy conditions.
func (c *Context) get(m map[string][]string, key string) (map[string]string, bool) { func (c *Context) get(m map[string][]string, key string) (map[string]string, bool) {
dicts := make(map[string]string) dicts := make(map[string]string)

View File

@ -609,6 +609,9 @@ func TestContextPostFormMultipart(t *testing.T) {
dicts = c.PostFormMap("nokey") dicts = c.PostFormMap("nokey")
assert.Equal(t, 0, len(dicts)) assert.Equal(t, 0, len(dicts))
formData := c.GetPostFormData()
assert.Equal(t, 9, len(formData))
} }
func TestContextSetCookie(t *testing.T) { func TestContextSetCookie(t *testing.T) {