MCPcopy Create free account
hub / github.com/goadesign/goa / extractCookies

Method extractCookies

http/codegen/service_data.go:2641–2718  ·  view source on GitHub ↗
(a *expr.MappedAttributeExpr, svcAtt *expr.AttributeExpr, svcCtx *codegen.AttributeContext, scope *codegen.NameScope)

Source from the content-addressed store, hash-verified

2639}
2640
2641func (sds *ServicesData) extractCookies(a *expr.MappedAttributeExpr, svcAtt *expr.AttributeExpr, svcCtx *codegen.AttributeContext, scope *codegen.NameScope) []*CookieData {
2642 var cookies []*CookieData
2643 codegen.WalkMappedAttr(a, func(name, elem string, required bool, _ *expr.AttributeExpr) error { // nolint: errcheck
2644 var hattr *expr.AttributeExpr
2645 if hattr = svcAtt.Find(name); hattr == nil {
2646 hattr = svcAtt
2647 }
2648 hattr = makeHTTPType(hattr)
2649 var (
2650 varn = scope.Name(codegen.Goify(name, false))
2651 typeRef = scope.GoTypeRef(hattr)
2652 ft = svcAtt.Type
2653
2654 fieldName string
2655 pointer bool
2656 fptr bool
2657 )
2658 pointer = a.IsPrimitivePointer(name, true)
2659 if expr.IsObject(svcAtt.Type) {
2660 fieldName = codegen.GoifyAtt(hattr, name, true)
2661 fptr = svcCtx.IsPrimitivePointer(name, svcAtt)
2662 ft = svcAtt.Find(name).Type
2663 }
2664 if pointer {
2665 typeRef = "*" + typeRef
2666 }
2667 c := &CookieData{
2668 Element: &Element{
2669 HTTPName: elem,
2670 AttributeName: name,
2671 AttributeData: &AttributeData{
2672 Name: name,
2673 Description: hattr.Description,
2674 FieldName: fieldName,
2675 FieldPointer: fptr,
2676 FieldType: ft,
2677 VarName: varn,
2678 TypeName: scope.GoTypeName(hattr),
2679 TypeRef: typeRef,
2680 Required: required,
2681 Pointer: pointer,
2682 Type: hattr.Type,
2683 Validate: codegen.AttributeValidationCode(hattr, nil, svcCtx, required, expr.IsAlias(hattr.Type), varn, name),
2684 DefaultValue: hattr.DefaultValue,
2685 Example: hattr.Example(sds.Root.API.ExampleGenerator),
2686 },
2687 },
2688 }
2689 for n, v := range a.Meta {
2690 switch n {
2691 case "cookie:max-age":
2692 c.MaxAge = v[0]
2693 case "cookie:path":
2694 c.Path = v[0]
2695 case "cookie:domain":
2696 c.Domain = v[0]
2697 case "cookie:secure":
2698 c.Secure = v[0] == "Secure"

Callers 3

buildPayloadDataMethod · 0.95
buildResponsesMethod · 0.95
buildErrorsDataMethod · 0.95

Calls 13

ExampleMethod · 0.95
WalkMappedAttrFunction · 0.92
GoifyFunction · 0.92
IsObjectFunction · 0.92
GoifyAttFunction · 0.92
AttributeValidationCodeFunction · 0.92
IsAliasFunction · 0.92
makeHTTPTypeFunction · 0.85
FindMethod · 0.80
GoTypeRefMethod · 0.80
GoTypeNameMethod · 0.80
NameMethod · 0.65

Tested by

no test coverage detected