百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
M

may_minihttp

> 编程语言
开源

mini http 实现在 may 上

922 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

mini http 实现在 may 上

may_minihttp

基于 may 实现的小型 http 服务器 此 crate 来自 tokio_minihttp。 但是,由于使用非常方便,您可以在服务中直接调用 MAY 块 API。

使用方法

首先,将以下内容添加到您的 Cargo.toml:

toml
may_minihttp = "0.1"

然后只需简单地实现您的 http 服务

extern crate may_minihttp;

use std::io;
use may_minihttp::{HttpServer, HttpService, Request, Response};

#[derive(Clone)]
struct HelloWorld;

impl HttpService for HelloWorld {
    fn call(&mut self, _req: Request, res: &mut Response) -> io::Result {
        res.body("Hello, world!");
        Ok(())
    }
}

// Start the server in `main`.
fn main() {
    let server = HttpServer(HelloWorld).start("0.0.0.0:8080").unwrap();
    server.join().unwrap();
}

性能

在我的笔记本电脑上,只测试了一个工作线程 可以使用以下命令启动服务器:

$ cargo run --example=hello-world --release

tokio_minihttp

bash
$ wrk http://127.0.0.1:8080 -d 10 -t 1 -c 200
Running 10s test @ http://127.0.0.1:8080
  1 threads and 200 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     1.98ms  284.06us  12.53ms   98.92%
    Req/Sec   101.64k     1.76k  103.69k    91.00%
  1011679 requests in 10.05s, 99.38MB read
Requests/sec: 100650.94
Transfer/sec:      9.89MB

may_minihttp

bash
$ wrk http://127.0.0.1:8080 -d 10 -t 1 -c 200
Running 10s test @ http://127.0.0.1:8080
  1 threads and 200 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     1.70ms  812.42us  20.17ms   97.94%
    Req/Sec   117.65k     7.52k  123.40k    88.00%
  1171118 requests in 10.08s, 115.04MB read
Requests/sec: 116181.73
Transfer/sec:     11.41MB

基准测试

根据 TechEmpower Framework Benchmark 评测,这是最快的 Web 框架之一。

许可证

本项目的许可证为以下两种之一

  • Apache 许可证,版本 2.0, (LICENSE-APACHE 或

[dependencies]

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rust

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言