(brand core.LarkBrand, req *larkcore.ApiReq)
| 263 | } |
| 264 | |
| 265 | func buildStreamURL(brand core.LarkBrand, req *larkcore.ApiReq) (string, error) { |
| 266 | requestURL := req.ApiPath |
| 267 | if !strings.HasPrefix(requestURL, "http://") && !strings.HasPrefix(requestURL, "https://") { |
| 268 | var pathSegs []string |
| 269 | for _, segment := range strings.Split(req.ApiPath, "/") { |
| 270 | if !strings.HasPrefix(segment, ":") { |
| 271 | pathSegs = append(pathSegs, segment) |
| 272 | continue |
| 273 | } |
| 274 | pathKey := strings.TrimPrefix(segment, ":") |
| 275 | pathValue, ok := req.PathParams[pathKey] |
| 276 | if !ok { |
| 277 | return "", errs.NewValidationError(errs.SubtypeInvalidArgument, "missing path param %q for %s", pathKey, req.ApiPath).WithParam(pathKey) |
| 278 | } |
| 279 | if pathValue == "" { |
| 280 | return "", errs.NewValidationError(errs.SubtypeInvalidArgument, "empty path param %q for %s", pathKey, req.ApiPath).WithParam(pathKey) |
| 281 | } |
| 282 | pathSegs = append(pathSegs, url.PathEscape(pathValue)) |
| 283 | } |
| 284 | endpoints := core.ResolveEndpoints(brand) |
| 285 | requestURL = strings.TrimRight(endpoints.Open, "/") + strings.Join(pathSegs, "/") |
| 286 | } |
| 287 | if query := req.QueryParams.Encode(); query != "" { |
| 288 | requestURL += "?" + query |
| 289 | } |
| 290 | return requestURL, nil |
| 291 | } |
| 292 | |
| 293 | func buildStreamBody(body interface{}) (io.Reader, string, error) { |
| 294 | switch typed := body.(type) { |
no test coverage detected