MCPcopy
hub / github.com/gin-gonic/gin / getMapFromFormData

Function getMapFromFormData

context.go:674–695  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

672// getMapFromFormData return a map which satisfies conditions.
673// It parses from data with bracket notation like "key[subkey]=value" into a map.
674func 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.
698func (c *Context) FormFile(name string) (*multipart.FileHeader, error) {

Callers 4

TestGetMapFromFormDataFunction · 0.85
GetQueryMapMethod · 0.85
GetPostFormMapMethod · 0.85

Calls

no outgoing calls

Tested by 2

TestGetMapFromFormDataFunction · 0.68