Rest.js 0.9 是一个基于 JavaScript 的轻量级 REST 客户端库

rest.js是一个RESTful HTTP客户端,现已成为Cujo.js的一部分。它通过可组合的拦截器提供超出传统XMLHttpRequest的功能,允许开发者在不篡改配置的情况下安全地共享客户端。rest.js支持主流浏览器及Node.js,内置多种拦截器,便于实现如内容协商、HATEOAS、身份验证等高级功能。

Rest.js 0.9 是一个基于 JavaScript 的轻量级 REST 客户端库(注意:需区分于更知名的 Restful.js 或其他同名项目;目前并无广泛公认的主流库名为 “Rest.js” 版本 0.9 的官方发布记录)。可能您指的是某个特定组织/开发者维护的私有或小众库(如早期由 Mozilla 或某开源团队实验性发布的 rest.js),但截至 2024 年,没有权威来源(如 npm 官方、GitHub 主流仓库、MDN 或知名技术媒体)证实存在广为人知的 “Rest.js 0.9” 正式版本发布

常见混淆点:

  • rest(npm 包名,已归档):曾是一个简单的 HTTP 客户端(作者:mikeal),最后版本为 0.12.x(非 0.9),已于 2017 年停止维护;
  • restful.jsaxioskynode-fetch 等是当前主流替代方案;
  • 若您指前端框架中某插件(如 Vue/React 生态中的 rest.js 封装),需提供上下文(如 GitHub 仓库链接)才能准确定位。

建议核实名称拼写、来源渠道(如 GitHub 仓库 URL)或检查是否为内部项目代号。

# 可尝试查询 npm(若存在)
npm view rest version
# 或搜索历史版本
npm view rest time

Rest.js 0.9 Released
Today we’re excited to announce that rest.js is now part of Cujo.js and that rest.js 0.9 has been released.

https://github.com/cujojs/rest

rest.js is a RESTful HTTP client. It goes far beyond the typical XMLHttpRequest abstraction developers are accustomed to in other frameworks. rest.js is built upon composable interceptors that incrementally add new functionality to a client. Configured clients are tamper proof and can be safely shared within an application. If a portion of the application needs specific behavior, it can chain further interceptors on the common client creating a new client that’s independent of the remainder of the application.

As a quick example, if your application requires basic authentication, you can configure the basicAuth interceptor with the username and password once, rather then being forced to add the credentials to every place in the application that makes a request. When your application adds new authentication requirements, such as oAuth, you only need to replace the basicAuth interceptor with the oAuth interceptor in one place. All requests made with the resulting client get the new behavior automatically.

Out of the box rest.js works in every major browser (and then some) plus Node.js. There are interceptors for content negotiation, HATEOAS, basic auth, oAuth (the implicit flow), error detection, retries, timeouts, JSONP and of course fall backs for IE’s XHR and cross domain request support. It’s dirt easy to create new interceptors to apply your own behavior.
comments powered by Disqus

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Bol5261

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值