Files
dify/web/service/request-guard.ts
2a6764edc5 feat: add reusable network access group APIs (#41025)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: CodingOnStar <hanxujiang@dify.com>
Co-authored-by: hjlarry <hjlarry@163.com>
Co-authored-by: yyh <92089059+lyzno1@users.noreply.github.com>
Co-authored-by: yyh <yuanyouhuilyz@gmail.com>
2026-10-20 05:52:18 +00:00

24 lines
740 B
TypeScript

/** Per-request hooks captured by the feature that owns the active surface. */
export type RequestGuard = {
beforeRequest: () => void
isActive: () => boolean
handleError: (status: number, data: unknown, error: object) => boolean
}
type RequestGuardFactory = (
url: string,
isPublicAPI: boolean,
method: string,
) => RequestGuard | undefined
let requestGuardFactory: RequestGuardFactory | undefined
/** Register at the feature entrypoint, before its request owners mount. */
export function registerRequestGuard(factory: RequestGuardFactory) {
requestGuardFactory = factory
}
export function captureRequestGuard(url: string, isPublicAPI = false, method = 'GET') {
return requestGuardFactory?.(url, isPublicAPI, method)
}