import { HttpErrorResponse, HttpResponse } from "@angular/common/http"; import { Router } from "@angular/router"; import { FaDecHttpAllConfig, FaHttpClientOptions, FaHttpDriveIn, RequestMethod, ResponseMetadata } from "./http.interface"; export declare abstract class AbstractHttpMessageHook { /** * 警告信息 * @param content * @param option */ abstract warning(content: string, option?: O): T; /** * 成功信息 * @param content * @param option */ abstract success(content: string, option?: O): T; /** * 错误信息提示 * @param content * @param option */ abstract error(content: string, option?: O): T; /** * 详情 * @param content * @param option */ abstract info(content: string, option?: O): T; /** * 加载提示 * @param content * @param option */ abstract loading(content: string, option?: O): T; /** * 移除 * @param content */ abstract remove(content: T): void; } export declare abstract class AbstractHttpErrorCallBackHook { readonly message: AbstractHttpMessageHook; /** * 401错误 一般是未登录 未授权 * @param router * @param res * @param currentConfig */ abstract exception401(router: Router, res: HttpErrorResponse, currentConfig: FaDecHttpAllConfig): void; /** * 重复请求 * @param router * @param currentConfig */ repeatRequest(router: Router, currentConfig: FaDecHttpAllConfig): void; /** * 500错误 一般为服务器错误 * @param router * @param res * @param currentConfig */ exception500(router: Router, res: HttpErrorResponse, currentConfig: FaDecHttpAllConfig): void; /** * 404错误 一般为请求地址不存在 * @param router * @param res * @param currentConfig */ exception404(router: Router, res: HttpErrorResponse, currentConfig: FaDecHttpAllConfig): void; /** * 405错误 一般为请求地址方法不允许 例如某个接口只允许get请求 而实际请求是post * @param router * @param res * @param currentConfig */ exception405(router: Router, res: HttpErrorResponse, currentConfig: FaDecHttpAllConfig): void; /** * 跨域问题 * @param router * @param res * @param currentConfig */ exceptionCors(router: Router, res: HttpErrorResponse, currentConfig: FaDecHttpAllConfig): void; /** * 超时 * @param router * @param res * @param currentConfig */ exceptionTimeout(router: Router, res: any, currentConfig: FaDecHttpAllConfig): void; /** * 403 错误 被禁止 一般为权限不足! * @param router * @param res * @param currentConfig */ forbidden(router: Router, res: HttpErrorResponse, currentConfig: FaDecHttpAllConfig): void; /** * 其他异常 * @param status 状态码 * @param router * @param res * @param currentConfig */ abstract otherException(status: number, router: Router, res: HttpErrorResponse, currentConfig: FaDecHttpAllConfig): void; } export declare class FaHttpResponse extends HttpResponse { /** * 成功标识 */ readonly success: boolean; /** * 接口 */ readonly apiUrl: string; /** * 提交的参数 */ readonly params: { [key: string]: string; }; /** * 请求类型 */ readonly method: RequestMethod; /** * 错误的响应体 */ error: T | null; /** * 执行后的信息描述 */ message: string; constructor(init?: {}); } export declare abstract class AbstractHttpHook { readonly errorHook: AbstractHttpErrorCallBackHook; readonly success: boolean; readonly body: T; protected static filterStatus(status: number, filterStatus?: number[]): boolean; /** * 转换 * @param res * @param currentConfig */ transform(res: HttpResponse | HttpErrorResponse, currentConfig: FaDecHttpAllConfig): void; /** * 全局信息提示 * @param result * @param msg * @param currentConfig */ abstract displayMsg(result: FaHttpResponse, msg: AbstractHttpMessageHook, currentConfig: FaDecHttpAllConfig): void; /** * 用于判断当前请求是否成功 * @param res * @param currentConfig */ abstract canSuccess(res: HttpResponse | HttpErrorResponse, currentConfig: FaDecHttpAllConfig): boolean; /** * 权限验证钩子 * @param acl */ /** * 用于解析result * @param result * @param body * @param currentConfig */ resolveResult(result: FaHttpResponse, body: T, currentConfig: FaDecHttpAllConfig): FaHttpResponse; resolveMetadata(response: HttpResponse | HttpErrorResponse, currentConfig: FaDecHttpAllConfig): ResponseMetadata; /** * 注册驱动钩子 * @param registeredDriveFn */ abstract registeredDrive(registeredDriveFn: (drive: FaHttpDriveIn) => void): void; /** * 生成请求URL 重写该方法可以修改默认生成URL规则 * @param options */ generateRequestURL(options: FaHttpClientOptions): string; }