MCPcopy Create free account
hub / github.com/kataras/iris / ReadURL

Method ReadURL

context/context.go:3186–3203  ·  view source on GitHub ↗

ReadURL is a shortcut of ReadParams and ReadQuery. It binds dynamic path parameters and URL query parameters to the "ptr" pointer struct value. The struct fields may contain "url" or "param" binding tags. If a validator exists then it validates the result too.

(ptr interface{})

Source from the content-addressed store, hash-verified

3184// The struct fields may contain "url" or "param" binding tags.
3185// If a validator exists then it validates the result too.
3186func (ctx *Context) ReadURL(ptr interface{}) error {
3187 values := make(map[string][]string, ctx.params.Len())
3188 ctx.params.Visit(func(key string, value string) {
3189 values[key] = strings.Split(value, "/")
3190 })
3191
3192 for k, v := range ctx.getQuery() {
3193 values[k] = append(values[k], v...)
3194 }
3195
3196 // Decode using all available binding tags (url, header, param).
3197 err := schema.Decode(values, ptr)
3198 if err != nil {
3199 return err
3200 }
3201
3202 return ctx.app.Validate(ptr)
3203}
3204
3205// ReadProtobuf binds the body to the "ptr" of a proto Message and returns any error.
3206// Look `ReadJSONProtobuf` too.

Callers 1

newAppFunction · 0.80

Calls 5

getQueryMethod · 0.95
LenMethod · 0.65
VisitMethod · 0.65
DecodeMethod · 0.65
ValidateMethod · 0.65

Tested by

no test coverage detected