/** * ProxyFromEnvironment 使用示例 * * 本文件演示如何在 HTTP Client 中使用代理环境变量支持 */ import { HttpClientService } from '../'; /** * 示例 1: 使用环境变量配置代理 (推荐方式) * * 设置环境变量: * export HTTP_PROXY=http://proxy.example.com:8080 * export HTTPS_PROXY=https://secure-proxy.example.com:8443 * export NO_PROXY=localhost,127.0.0.1,.internal.com */ export declare class ProxyFromEnvironmentExample { private readonly httpClient; constructor(httpClient: HttpClientService); /** * 使用装饰器从环境变量读取代理配置 */ fetchWithProxyFromEnv(): Promise; /** * 直接配置请求时指定从环境变量读取代理 */ fetchWithConfiguredProxy(): Promise; } /** * 示例 2: 带认证的代理环境变量 * * 设置环境变量: * export HTTP_PROXY=http://username:password@proxy.example.com:8080 */ export declare class ProxyWithAuthExample { private readonly httpClient; constructor(httpClient: HttpClientService); fetchWithAuthenticatedProxy(): Promise; } /** * 示例 3: NO_PROXY 使用示例 * * 设置环境变量: * export HTTP_PROXY=http://proxy.example.com:8080 * export NO_PROXY=localhost,127.0.0.1,.internal.com,.local */ export declare class NoProxyExample { private readonly httpClient; constructor(httpClient: HttpClientService); fetchExternalApi(): Promise; fetchInternalApi(): Promise; fetchLocalhost(): Promise; } /** * 示例 4: 混合使用 - 部分请求使用代理,部分不使用 */ export declare class MixedProxyExample { private readonly httpClient; constructor(httpClient: HttpClientService); fetchWithProxy(): Promise; fetchWithoutProxy(): Promise; } /** * 示例 5: 企业环境中的实际使用场景 * * 在 docker-compose.yml 或 Kubernetes 配置中设置: * environment: * - HTTP_PROXY=http://proxy-user:proxy-pass@corporate-proxy.company.com:8080 * - HTTPS_PROXY=http://proxy-user:proxy-pass@corporate-proxy.company.com:8080 * - NO_PROXY=localhost,127.0.0.1,.company.com,.svc.cluster.local */ export declare class EnterpriseProxyExample { private readonly httpClient; constructor(httpClient: HttpClientService); /** * 访问外部 API(使用企业代理) */ fetchFromExternalApi(): Promise; /** * 访问内部服务(不使用代理) */ fetchFromInternalService(): Promise; /** * 访问 Kubernetes 集群内服务(不使用代理) */ fetchFromK8sService(): Promise; } /** * 示例 6: 开发环境调试代理 * * 本地开发时使用 Charles、Fiddler 等代理工具调试: * export HTTP_PROXY=http://localhost:8888 * export HTTPS_PROXY=http://localhost:8888 */ export declare class DevelopmentProxyExample { private readonly httpClient; constructor(httpClient: HttpClientService); debugRequest(): Promise; } /** * 示例 7: 程序化检查代理配置 */ export declare class ProxyUtilityExample { checkProxyConfiguration(): Promise; } /** * 模块配置示例 */ export declare const httpClientModuleConfig: { globalProxyFromEnv: { imports: { proxy: { enabled: boolean; fromEnvironment: boolean; }; }[]; }; selectiveProxy: { imports: { proxy: { enabled: boolean; }; }[]; }; }; /** * 环境变量配置示例 */ export declare const environmentVariablesExamples: { basic: string; withAuth: string; specialChars: string; enterprise: string; development: string; };