3.11路径片段
添加 URL 路径片段。
设置路径片段#
添加 URL 路径片段。
HttpRequestBuilder.Get("https://furion.net/") .WithPathSegment("user") // 添加单个路径片段 .WithPathSegments(["detail", "edit"]) // 添加多个路径片段生成的最终 URL 为:https://furion.net/user/detail/edit。
若存在重复的路径片段,它们将在后续追加中重复出现(如:/docs/docs/users/docs/)。
设置移除的路径片段#
移除指定的路径片段。
HttpRequestBuilder.Get("https://furion.net/docs/login/users") .RemovePathSegments("docs", "user"); // 移除多个路径片段生成的最终 URL 为:https://furion.net/login。
在发送 HTTP 请求之前,将移除配置中指定的待移除路径片段集合。也就是说,RemovePathSegments 方法会在所有 WithPathSegment[s] 方法调用之后执行。