PathParams computes a mapped attribute containing the subset of e.Params that describe path parameters.
()
| 143 | // PathParams computes a mapped attribute containing the subset of e.Params that |
| 144 | // describe path parameters. |
| 145 | func (e *HTTPEndpointExpr) PathParams() *MappedAttributeExpr { |
| 146 | obj := Object{} |
| 147 | v := &ValidationExpr{} |
| 148 | pat := e.Params.Attribute() // need "attribute:name" style keys |
| 149 | for _, r := range e.Routes { |
| 150 | for _, p := range r.Params() { |
| 151 | att := pat.Find(p) |
| 152 | if att == nil { |
| 153 | continue |
| 154 | } |
| 155 | obj.Set(p, att) |
| 156 | if e.Params.IsRequired(p) { |
| 157 | v.AddRequired(p) |
| 158 | } |
| 159 | } |
| 160 | } |
| 161 | at := &AttributeExpr{Type: &obj, Validation: v} |
| 162 | return NewMappedAttributeExpr(at) |
| 163 | } |
| 164 | |
| 165 | // QueryParams computes a mapped attribute containing the subset of e.Params |
| 166 | // that describe query parameters. |
no test coverage detected