(param *parser.Param, nth, numParams int)
| 290 | } |
| 291 | |
| 292 | func (l *loader) loadActionParam(param *parser.Param, nth, numParams int) *ActionParam { |
| 293 | dec, err := param.Definition() |
| 294 | if err != nil { |
| 295 | l.Bail(fmt.Errorf("controller: unable to find param definition for %s. %w", param.Type(), err)) |
| 296 | } |
| 297 | ap := new(ActionParam) |
| 298 | ap.Name = l.loadActionParamName(param, nth) |
| 299 | ap.Pascal = gotext.Pascal(ap.Name) |
| 300 | ap.Snake = gotext.Lower(gotext.Snake(ap.Name)) |
| 301 | ap.Type = l.loadType(param.Type(), dec) |
| 302 | ap.Tag = fmt.Sprintf("`json:\"%[1]s\"`", tagValue(ap.Snake)) |
| 303 | ap.Kind = string(dec.Kind()) |
| 304 | switch { |
| 305 | // Single struct input |
| 306 | case numParams == 1 && dec.Kind() == parser.KindStruct: |
| 307 | ap.Variable = "in" |
| 308 | // Handle context.Context |
| 309 | case ap.IsContext(): |
| 310 | ap.Variable = `httpRequest.Context()` |
| 311 | default: |
| 312 | ap.Variable = "in." + ap.Pascal |
| 313 | } |
| 314 | return ap |
| 315 | } |
| 316 | |
| 317 | func (l *loader) loadActionParamName(param *parser.Param, nth int) string { |
| 318 | name := param.Name() |
no test coverage detected