MCPcopy Index your code
hub / github.com/bilibili/http-service

github.com/bilibili/http-service @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
236 symbols 471 edges 67 files 15 documented · 6%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

HTTP Service · GitHub license

什么是 HTTP Service

HTTP Service(HTTP服务),是一个可以用于Web前端 CSR(客户端渲染)以及 SSR(服务端渲染)场景下统一的HTTP Request SDK,我们通常称其为请求库或者统一请求库

其设计模式主要借鉴于服务端框架的 middleware 模式,如koa,在发起请求部分,我们保留了 Axios 用户发起请求的习惯。

在发起请求的部分,我们遵循 WHATWG Fetch 规范,使用 Fetch API 作为发起请求中间件的内核,于是在现代浏览器中,你可以不使用任何 polyfill 的情况下使用 HTTP Service。当然我们也为旧版浏览器提供了 polyfill 方案以及为NodeJS用户提供了服务端的使用方案。

通过使用 HTTP Service,你可以通过装配中间件的方式来优雅地组织逻辑发起HTTP请求。

环境支持

Browser

Chrome Firefox Safari Opera Edge IE
Latest ✔ Latest ✔ Latest ✔ Latest ✔ Latest ✔ 11 ✔

NodeJS

版本 使用方案
低于 16.5.0 推荐使用 node-fetch 作为fetch中间件内核
16.5.0 及以上 按您喜好使用 node-fetch 或者 undici 作为fetch中间件内核
高于 18.0.0 已内置fetch

开始上手

请前往文档站点,查看快速开始

Extension points exported contracts — how you extend this code

IHttpService (Interface)
(no doc) [3 implementers]
packages/http-svc/types/exports.d.ts
UniosStatic (Interface)
(no doc) [1 implementers]
packages/unios/index.d.ts
IMiddlewareHandlerConfig (Interface)
(no doc)
packages/middleware/types/middleware.d.ts
IPayload (Interface)
(no doc)
packages/server-fetch/index.ts
IPayload (Interface)
(no doc)
packages/xhr/index.ts
IHttpSvcAssembleControl (Interface)
(no doc) [2 implementers]
packages/http-svc/types/exports.d.ts
UniosResetPayload (Interface)
(no doc)
packages/unios/index.ts
IMiddlewareHandler (Interface)
(no doc)
packages/middleware/types/middleware.d.ts

Core symbols most depended-on inside this repo

with
called by 45
packages/http-svc/src/control/assemble.ts
request
called by 36
packages/unios/index.d.ts
getBuiltInMiddlewareName
called by 24
packages/http-svc/src/shared.ts
get
called by 7
packages/http-svc/types/exports.d.ts
createError
called by 6
packages/http-svc/src/shared.ts
resolve
called by 6
scripts/start.ts
disable
called by 5
packages/http-svc/types/exports.d.ts
setObjectValue
called by 4
packages/http-svc/src/shared.ts

Shape

Function 71
Class 63
Method 55
Interface 46
Enum 1

Languages

TypeScript100%

Modules by API surface

packages/http-svc/types/exports.d.ts20 symbols
packages/http-svc/src/shared.ts19 symbols
packages/http-svc/src/control/assemble.ts16 symbols
packages/unios/index.ts12 symbols
packages/http-svc/src/__tests__/base.ts11 symbols
packages/unios/index.d.ts10 symbols
packages/http-svc/src/core.ts9 symbols
packages/xhr/index.ts8 symbols
packages/http-svc/src/control/request.ts7 symbols
packages/server-fetch/index.ts6 symbols
packages/http-svc/src/control/config.ts6 symbols
scripts/start.ts5 symbols

For agents

$ claude mcp add http-service \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact