getMapFromFormData return a map which satisfies conditions. It parses from data with bracket notation like "key[subkey]=value" into a map.
(m map[string][]string, key string)
| 672 | // getMapFromFormData return a map which satisfies conditions. |
| 673 | // It parses from data with bracket notation like "key[subkey]=value" into a map. |
| 674 | func getMapFromFormData(m map[string][]string, key string) (map[string]string, bool) { |
| 675 | d := make(map[string]string) |
| 676 | found := false |
| 677 | keyLen := len(key) |
| 678 | |
| 679 | for k, v := range m { |
| 680 | if len(k) < keyLen+3 { // key + "[" + at least one char + "]" |
| 681 | continue |
| 682 | } |
| 683 | |
| 684 | if k[:keyLen] != key || k[keyLen] != '[' { |
| 685 | continue |
| 686 | } |
| 687 | |
| 688 | if j := strings.IndexByte(k[keyLen+1:], ']'); j > 0 { |
| 689 | found = true |
| 690 | d[k[keyLen+1:keyLen+1+j]] = v[0] |
| 691 | } |
| 692 | } |
| 693 | |
| 694 | return d, found |
| 695 | } |
| 696 | |
| 697 | // FormFile returns the first file for the provided form key. |
| 698 | func (c *Context) FormFile(name string) (*multipart.FileHeader, error) { |
no outgoing calls