gpt4 book ai didi

android - 改造 - 插入查询后将文本附加到端点的末尾

转载 作者:行者123 更新时间:2023-11-30 01:15:06 26 4
gpt4 key购买 nike

<分区>

我想生成类似 /api/method?page=1.json 的终点,但问题是查询将像 /api/method.json 一样插入到最后?page=1

// from my service
@GET("method.json")
Call<Void> method(@Query("page") int page);

// building retrofit
new Retrofit.Builder()
.baseUrl(URL)
.client(httpClient)
.addConverterFactory(GsonConverterFactory.create())
.build();

更新/ 以下作品,但我@Blackbelt 的回答是最好的。

HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.setLevel(BuildConfig.DEBUG ? HttpLoggingInterceptor.Level.BASIC : HttpLoggingInterceptor.Level.NONE);
return new OkHttpClient.Builder()
.addInterceptor(logging)
.addInterceptor(new Interceptor() {
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
request = request.newBuilder().url(request.url().toString().concat(".json")).build();
return chain.proceed(request);
}
})
.build();

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com