All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hiczp.bilibili.api.interceptor.AddAppKeyInterceptor Maven / Gradle / Ivy

There is a newer version: 0.2.0
Show newest version
package com.hiczp.bilibili.api.interceptor;

import com.hiczp.bilibili.api.BilibiliClientProperties;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

import java.io.IOException;

public class AddAppKeyInterceptor implements Interceptor {
    private BilibiliClientProperties bilibiliClientDefinition;

    public AddAppKeyInterceptor(BilibiliClientProperties bilibiliClientDefinition) {
        this.bilibiliClientDefinition = bilibiliClientDefinition;
    }

    @Override
    public Response intercept(Chain chain) throws IOException {
        Request request = chain.request();
        return chain.proceed(request.newBuilder().url(
                request.url().newBuilder()
                        .addQueryParameter("appkey", bilibiliClientDefinition.getAppKey())
                        .build()
        ).build());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy