MCPcopy
hub / github.com/larksuite/cli / buildStreamURL

Function buildStreamURL

internal/client/client.go:265–291  ·  view source on GitHub ↗
(brand core.LarkBrand, req *larkcore.ApiReq)

Source from the content-addressed store, hash-verified

263}
264
265func 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
293func buildStreamBody(body interface{}) (io.Reader, string, error) {
294 switch typed := body.(type) {

Callers 1

DoStreamMethod · 0.85

Calls 3

NewValidationErrorFunction · 0.92
ResolveEndpointsFunction · 0.92
WithParamMethod · 0.80

Tested by

no test coverage detected