Httpbeast
A highly performant, multi-threaded HTTP 1.1 server written in Nim.
Install / Use
/learn @dom96/HttpbeastREADME
httpbeast
A highly performant, multi-threaded HTTP 1.1 server written in Nim.
The main goal of this project is performance, when it was started the goal was to get the fastest possible HTTP server written in pure Nim, it has held the title of the fastest Nim HTTP server since its initial release. In 2018 HttpBeast reached the top 10 in the TechEmpower benchmarks beating many established HTTP servers implemented in other programming languages. Httpbeast has been used successfully in many projects, for example the Nim Forum.
:information_source: Unless you know what you're doing (for example writing something resource constrained or your own web framework), you are better off using Jester (which is built on Httpbeast) or another web framework.
:information_source: This HTTP server has been designed to utilise epoll-like OS APIs and as such does not support Windows by-design.
:warning: This library is not yet hardened against common HTTP security exploits. If you're using it in production you should do so behind a reverse proxy like nginx.
Features
Current features include:
- Built on the Nim
selectorsmodule which makes efficient use of epoll on Linux and kqueue on macOS. - Automatic parallelization, just make sure to compile with
--threads:on. - Support for HTTP pipelining.
- On-demand parser so that only the requested data is parsed.
- Integration with Nim's
asyncdispatchallowing async/await to be used in the request callback whenever necessary.
Getting started
Create a helloHttp.nimble file:
# 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.4.0"
Create a src/helloHttp.nim file:
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)
Run via: nimble c -r helloHttp.nim
Related Skills
node-connect
344.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
96.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
344.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
344.1kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
