拥有始终以HTTP 200响应的服务器的最简单方法

发布于 2025-02-07 21:55:42 字数 311 浏览 2 评论 0原文

我正在使用多个微服务,有时我只想忽略微服务,然后用服务器替换它,该服务器将始终以HTTP 200响应任何请求。

根据任何请求,我的意思是每种类型的请求(post,get,patch ..),并在服务器上和域的任何路由上制作的任何车身或标头(例如server.dev/somewhereserver.dev/another/endpoint

您知道有任何现有网站吗?

是否有一种简单/快速运行最小的服务器可以在本地执行此操作的方法?

显然,这仅适用于我的开发环境,我不需要在生产中使用它。

I'm working with multiple microservices, and sometimes I just want to ignore a microservice and replace it by a server that will always respond with HTTP 200 for any request.

By any request, I mean every type of requests (POST, GET, PATCH ..) with any body or header made on the server and on any route of the domain (e.g. server.dev/somewhere, server.dev/another/endpoint)

Do you know any existing website that does that ?

Is there an easy/fast way to run a minimal server that would do that locally ?

Obviously, it's just for my development environment, I don't need to use this in production.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

幼儿园老大 2025-02-14 21:55:42

一种简单的方法是用 node.js
简单的内容:

const http = require('http');

/*
 *  tiny webserver that always responds 200
 */

http.createServer(function (req, res) {
    res.writeHead(200);
    res.end();
}).listen(4000);

上面在端口4000上听,可以在http:// localhost:4000/可以访问

One easy way to do this is with node.js
Something as simple as:

const http = require('http');

/*
 *  tiny webserver that always responds 200
 */

http.createServer(function (req, res) {
    res.writeHead(200);
    res.end();
}).listen(4000);

The above listens on port 4000 and would be accessable at http://localhost:4000/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文