httpbeast 正在参加 2021 年度 OSC 中国开源项目评选,请投票支持!
httpbeast 在 2021 年度 OSC 中国开源项目评选 中已获得 {{ projectVoteCount }} 票,请投票支持!
2021 年度 OSC 中国开源项目评选 正在火热进行中,快来投票支持你喜欢的开源项目!
2021 年度 OSC 中国开源项目评选 >>> 中场回顾
httpbeast 获得 2021 年度 OSC 中国开源项目评选「最佳人气项目」 !
授权协议 MIT
开发语言 Nim 查看源码 »
操作系统 跨平台
软件类型 开源软件
所属分类 服务器软件HTTP服务器
开源组织
地区 不详
投 递 者
适用人群 未知
收录时间 2021-09-17

软件简介

httpbeast 是使用 Nim 语言编写的高性能、多线程 HTTP 1.1 服务器。

主要特性

  • 基于 Nimselectors模块构建,可以有效地利用 Linux 上的 epoll 和 macOS 上的 kqueue
  • 自动并行化,只需确保编译时添加--threads:on参数即可
  • 支持 HTTP pipelining
  • 按需使用的解析器,可用于仅解析请求的数据
  • 与 Nim 的集成asyncdispatch支持在必要时在请求回调中使用 async/await

示例代码

创建helloHttp.nimble文件:

# Package

version       = "0.1.0"
author        = "Your Name"
description   = "Your Description"
license       = "MIT"
srcDir        = "src"
bin           = @["helloHttp"]


# Dependencies

requires "nim >= 1.0.0"
requires "httpbeast >= 0.3.0"

创建src/helloHttp.nim文件:

import options, asyncdispatch

import httpbeast

proc onRequest(req: Request): Future[void] =
  if req.httpMethod == some(HttpGet):
    case req.path.get()
    of "/":
      req.send("Hello World")
    else:
      req.send(Http404)

run(onRequest)

通过nimble c -r helloHttp.nim运行。

展开阅读全文

代码

的 Gitee 指数为
超过 的项目

评论

点击加入讨论🔥(2) 发布并加入讨论🔥
暂无内容
发表了博客
{{o.pubDate | formatDate}}

{{formatAllHtml(o.title)}}

{{parseInt(o.replyCount) | bigNumberTransform}}
{{parseInt(o.viewCount) | bigNumberTransform}}
没有更多内容
暂无内容
发表了问答
{{o.pubDate | formatDate}}

{{formatAllHtml(o.title)}}

{{parseInt(o.replyCount) | bigNumberTransform}}
{{parseInt(o.viewCount) | bigNumberTransform}}
没有更多内容
暂无内容
暂无内容
2 评论
6 收藏
分享
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部