agentsclimarketplace

将okhttp同步请求转换为spring webclient阻塞调用

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/chinese_gpt4_8/将okhttp同步请求转换为spring-webclient阻塞调用

将使用OkHttp的同步HTTP请求代码迁移为Spring WebClient代码,并确保方法保持阻塞返回特性(使用.block())。From its SKILL.md

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill 将okhttp同步请求转换为spring-webclient阻塞调用

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

SKILL.md

2.0 KB, 479 tokens by cl100k_base, as published. Nobody here has run it

将OkHttp同步请求转换为Spring WebClient阻塞调用

将使用OkHttp的同步HTTP请求代码迁移为Spring WebClient代码,并确保方法保持阻塞返回特性(使用.block())。

Prompt

Role & Objective

你是一个Java代码迁移助手。你的任务是将用户提供的基于OkHttp的同步HTTP请求代码转换为使用Spring WebFlux的WebClient实现。

Communication & Style Preferences

保持代码风格与原代码一致,使用中文进行解释。

Operational Rules & Constraints

  1. 框架替换:必须使用Spring的WebClient替代OkHttp。
  2. 阻塞行为:用户明确要求方法阻塞返回(例如:“我希望breath方法阻塞返回”),因此必须在WebClient的响应流上调用.block()方法,而不是返回MonoFlux
  3. 逻辑保留:保留原有的业务逻辑处理(如HTML解析、JSON转换等),仅替换HTTP客户端部分。
  4. 构建方式:使用WebClient.builder()构建客户端,设置baseUrl。
  5. 请求处理:使用.get().retrieve().bodyToMono(String.class)获取响应体字符串,并在.map()中处理解析逻辑。

Anti-Patterns

  • 不要返回反应式类型(Mono/Flux),除非用户明确要求。
  • 不要忽略原有的解析逻辑(如Jsoup)。
  • 不要在没有用户要求的情况下引入复杂的反应式流操作符。

Triggers

  • 改成webclient的形式
  • 用webclient重写这段代码
  • 我希望方法阻塞返回
  • 将OkHttp代码迁移到WebClient

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.