LinuxDo 新帖推送
184 subscribers
253K photos
315K links
Download Telegram
标题: 基于Spring Framework 6的跨服务请求客户端-HTTP Interface
作者: #猫娘
板块: #开发调优
编号: 1410150
帖子: https://linux.do/t/topic/1410150
时间: 2026-01-06 09:44:54
摘要:
从 https://linux.do/t/topic/1409391?u=furry 继续讨论。
在前段时间公司要自己搞个电商平台,首选开发语言用java,架子用springboot,我作为研发负责人。
在立项初期我准备上cloud,但是老板没同意,说后面再迭代,我因为刚来这家公司我也就没好说什么,单体就单体呗。
在后面的开发过程中产品提出要增加一个供应商服务端,两端会有频繁的数据交互,我思考了半天有几个方案,要么是谷歌的grpc,要么是阿里的dubbo,或者是openfeign,不过grpc要写protobuf,dubbo以前用的2.8版本遇到兼容性问题现在好多年不用而且时间给的少我怕来不及,openfeign 又没脱离cloud依赖,需要引入一堆maven依赖,思来想去总不能直接http吧,这不胶水架构了么。
最后吧,还是用了胶水架构,不过是好用一点的,这就是HTTP Interface啦,因为当时是我负责搭建架子的,所以我采用了基于jdk17的boot3.5,正好是基于Spring Framework 6的。
这个东西用起来门槛非常低,只需要一个配置:

@Configuration
@RequiredArgsConstructor
@Slf4j
public class HttpInterfaceConfig {

private final TenantPropagator tenantPropagator;

@Value("${service.auth.secret-key}")
private String secretKey;

private WebClient.Builder createWebClientBuilder(String baseUrl) {
return WebClient.builder()
.baseUrl(baseUrl)
.filter(this::addAuthHeaders) // 添加认证过滤器
.defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
}

/**
* 为每次请求动态添加认证头
*/
private Mono<ClientResponse> addAuthHeaders(ClientRequest request, ExchangeFunction next) {
// 每次请求时动态生成时间戳、随机数和签名
long timestamp = System.currentTimeMillis();
String nonce = UUID.randomUUID().toString().replace("-", "").substring(0, 16);
String signature = HmacSignUtils.generateTimestampSignature(timestamp, nonce, secretKey);
log.debug("🔐 动态生成认证头 - timestamp: {}, nonce: {}, signature: {}",
timestamp, nonce, signature);
// 创建新的请求,添加认证头
ClientRequest newRequest = ClientRequest.from(request)
.header("X-Internal-Service", "true")
.header("X-Service-Timestamp", String.valueOf(timestamp))
.header("X-Service-Nonce", nonce)
.header("X-Service-Signature", signature)
.build();
return next.exchange(newRequest);
}


@Bean
public OperationPlatFormApiClient operationPlatformApiClient(
@Value("${service.operationPlatform.url}") String baseUrl) {
log.info("=== operationPlatformApiClient 配置信息 ===");
log.info("baseUrl: {}", baseUrl);
log.info("secretKey: {}", secretKey != null ? "已配置" : "未配置");
// 创建基础的 WebClient Builder
WebClient.Builder webClientBuilder = createWebClientBuilder(baseUrl);
// 传播租户信息
webClientBuilder = tenantPropagator.propagateTenant(webClientBuilder);
WebClient webClient = webClientBuilder.build();
WebClientAdapter adapter = WebClientAdapter.create(webClient);
HttpServiceProxyFactory factory = HttpServiceProxyFactory
.builderFor(adapter)
.build();
OperationPlatFormApiClient client = factory.createClient(OperationPlatFormApiClient.class);
log.info(" operationPlatformApiClient 创建成功");
return client;
}

@Bean
public SupplierApiClient supplierApiClient(
@Value("${service.supplier.url}") String baseUrl) {
log.info("=== SupplierApiClient 配置信息 ===");
log.info("baseUrl: {}", baseUrl);
log.info("secretKey: {}", secretKey != null ? "已配置" : "未配置");
// 创建基础的 WebClient Builder
WebClient.Builder webClientBuilder = createWebClientBuilder(baseUrl);
// 传播租户信息
webClientBuilder = tenantPropagator.propagateTenant(webClientBuilder);
WebClient webClient = webClientBuilder.build();
WebClientAdapter adapter = WebClientAdapter.create(webClient);
HttpServiceProxyFactory factory = HttpServiceProxyFactory
.builderFor(adapter)
.build();
SupplierApiClient client = factory.createClient(SupplierApiClient.class);
log.info(" SupplierApiClient 创建成功");
return client;
}

@Bean
public CrowdsourcingApiClient crowdsourcingApiClient(
@Value("${ser
标题: B站不知道看啥,一人推荐一个宝藏UP主,分享你的精神审美!!!
作者: #One_Youndcris
板块: #搞七捻三
编号: 1410152
帖子: https://linux.do/t/topic/1410152
时间: 2026-01-06 09:45:05
摘要:
我最近看的是李正讲史
标题: 你们都是怎么调教cc的
作者: #对方正在长头发
板块: #开发调优
编号: 1410153
帖子: https://linux.do/t/topic/1410153
时间: 2026-01-06 09:45:20
摘要:
最近在薅公益站的claude code,也感谢各位公益佬们的付出,太强了,但是我想看看你们调教cc的提示词是怎么样的
标题: 【求助】codex错误提示:上下文空间不错问题
作者: #大好丶先森
板块: #搞七捻三
编号: 1410154
帖子: https://linux.do/t/topic/1410154
时间: 2026-01-06 09:45:20
摘要:
这是额度用完了?已经新建对话了,还是显示上下文灭有空间~~求大佬帮助
标题: 为何credit积分两天没涨了?
作者: #Skinger
板块: #搞七捻三
编号: 1410158
帖子: https://linux.do/t/topic/1410158
时间: 2026-01-06 09:45:56
摘要:
标题: 九华山景色分享
作者: #ChenZiL
板块: #搞七捻三
编号: 1410159
帖子: https://linux.do/t/topic/1410159
时间: 2026-01-06 09:46:02
摘要:
元旦去了一趟九华山,正好前几天下了雪,上面景色清幽壮丽,给佬友们分享一些图片(拍的不好见谅)




另外,如果有佬友想去玩的话,最好提前关注一下天气,我们那天爬山的时候有些台阶结冰了很滑。
标题: 日子也是好起来了,萌新第一次获取这么多ldc
作者: #xking
板块: #搞七捻三
编号: 1410163
帖子: https://linux.do/t/topic/1410163
时间: 2026-01-06 09:46:24
摘要:
标题: 又是普涨的行情,新高了
作者: #谷歌学术
板块: #搞七捻三
编号: 1410169
帖子: https://linux.do/t/topic/1410169
时间: 2026-01-06 09:47:25
摘要:
但是我钱呢,钱呢???
标题: GeminiCli求助
作者: #zhuanjiao
板块: #开发调优
编号: 1410172
帖子: https://linux.do/t/topic/1410172
时间: 2026-01-06 09:48:09
摘要:
现在必须登录才能使用嘛。我配置了环境变量想用自己的api怎么输入gemini启动每次都直接跳转登录了呢。
标题: Baserow-开源版的Airtable
作者: #josenlou
板块: #搞七捻三
编号: 1410180
帖子: https://linux.do/t/topic/1410180
时间: 2026-01-06 09:49:19
摘要:
Baserow 是一款对标Airtable
但主打开源的数据库软件
除了可以透过以下的github部属自己的本地服务外


github.com






GitHub - baserow/baserow: Build databases, automations, apps & agents with...

Build databases, automations, apps & agents with AI — no code. Open source platform available on cloud and self-hosted. GDPR, HIPAA, SOC 2 compliant. Best Airtable alternative.












也可以透过官方的平台创建云数据库
目前看起来价格确实比Airtable本身更多(免费方案)

有兴趣可以试看看
标题: 反代 GCP 免费鸡流量怎么算
作者: #caoyufei
板块: #搞七捻三
编号: 1410187
帖子: https://linux.do/t/topic/1410187
时间: 2026-01-06 09:50:26
摘要:
用A机器反代 GCP免费鸡
A机器开了CF小黄云,免费鸡还走200G的流量不
标题: vibe 的一个小玩具,支持将 Antigravity 的额度用于 Claude Code, Codex 的工具,支持 docker
作者: #小野花
板块: #资源荟萃
编号: 1410191
帖子: https://linux.do/t/topic/1410191
时间: 2026-01-06 09:50:54
摘要:
Antigravity Manager 的简化版,去除客户端,增加 WebUI ,支持 docker 部署 与 非本地 Google Auth



AntiProxy
标题: 自己部署的newapi,里面的apikey去找供应商还是找中转?
作者: #BingBing
板块: #开发调优
编号: 1410208
帖子: https://linux.do/t/topic/1410208
时间: 2026-01-06 09:55:53
摘要:
因为我也是小白,自己刚学会用docker,前几天刚部署了一套newapi,我现在发愁去哪里找供应商,因为我部署下来也是我们内部的人用不会对外开放,没招了,实在不知道去哪里找,来问问老哥们
标题: 关于 Win+Scoop 环境下 Sing-box 防火墙路径问题及 VPN 都在并存的小发现
作者: #Excalicode
板块: #搞七捻三
编号: 1410209
帖子: https://linux.do/t/topic/1410209
时间: 2026-01-06 09:56:02
摘要:
环境配置
Win + scoop + WinSW + sing-box 1.12.14 裸核
问题一:切换 mixed 模式断网与防火墙路径
之前一直用的 tun 的 gvisor 堆栈,最近看群里讨论 mixed 模式(也是默认模式),就想换过来试试,结果一改配置直接断网。
排查与解决:
在群友提醒下怀疑是防火墙问题。

尝试直接关闭防火墙,网络恢复,确认锅在防火墙。
检查防火墙规则,发现确实有一条 sing-tun 的放行规则,路径指向 E:\MyScoop\Scoop\apps\sing-box\current\sing-box.exe。
关键点来了:Scoop 的 current 是一个软连接。我尝试把防火墙规则改为实际的版本路径 E:\MyScoop\Scoop\apps\sing-box\1.12.14\sing-box.exe,启用防火墙后网络正常了。

求教: 看来 Windows 防火墙似乎不认 Scoop 的 current 软连接路径?有没有懂这块底层机制的佬友科普一下原理?
问题二:关于公司 VPN 并存与 local DNS 的源码发现
顺道分享一个近期折腾 VPN 并存时发现的坑。
场景是日常挂 sing-box 和公司 VPN。VPN 启动后会生成独立虚拟网卡。
目前的笨办法:
必须显式指定出站接口和 DNS 转发。
创建绑定 VPN 网卡的 outbound:
{
"tag": "company-network",
"type": "direct",
"bind_interface": "controller" // controller 为网卡名称
}

定义内网 DNS 并指定出口:
{
"tag": "Company-DNS",
"type": "udp",
"server": "12.0.0.1", // 公司内网DNS
"detour": "company-network"
}

路由规则指定域名走该 DNS:
{
"action": "route",
"domain_suffix": ["company.net"],
"server": "Company-DNS",
"strategy": "prefer_ipv4"
}

尝试简化失败:
原本以为可以用官方文档里的 local 服务来简化配置,让 sing-box 自动读取系统 DNS:
{
"type": "local",
"tag": "dns_local"
}

配置后发现无法解析公司内网域名。
原因分析:
大概翻了一下 sing-box 源码,local 确实是读取系统里的上游 DNS 列表,但它在发查询时会检查网关。
由于我们公司的 VPN 网卡(controller)没有配置 IPv4 默认网关,源码里有一句判断:
if address.FirstGatewayAddress == nil {
continue
}

导致这张网卡直接被跳过了。给同样有 VPN 并存需求的兄弟排个雷。
求教: 佬友们有没有需要公司 VPN 和代理工具同时使用的场景呢?可以分享下使用技巧。
标题: 现在还有人在玩白银套利吗
作者: #shmilyxwx
板块: #搞七捻三
编号: 1410210
帖子: https://linux.do/t/topic/1410210
时间: 2026-01-06 09:56:02
摘要:
申购费除开,感觉没有多少利润了