GithubHelp home page GithubHelp logo

httpbeast_fork's Introduction

FORK OF HTTPBEAST

A fork of httpbeast updated to work with Nim version 2.0. Package has been renamed to httpbeastfork.

Reason:

  • Package not being tagged (new versions not available)
  • Full support for Nim 2.0

Jester & httpbeast:

  • This package can be used with the original jester package, but it is recommended to use the fork jesterfork instead.

Breaking changes / Info:

  • Package renamed to httpbeastfork from version 1.0.0. Previous versions (tags) uses the original package name httpbeast.
  • The previous tag, v0.4.2, includes the needed fixes to allow the original jester package to work with Nim 2.0.
  • This fork is a spin-off of the original httpbeast package v0.4.0. The original package is still available but does not support Nim 2.0.
  • Nim support bumped to >= 1.4.8

httpbeastfork

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.

ℹ️ 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.

ℹ️ This HTTP server has been designed to utilise epoll-like OS APIs and as such does not support Windows by-design.

⚠️ 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 selectors module 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 asyncdispatch allowing 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 "httpbeastfork >= 0.4.0"

Create a src/helloHttp.nim file:

import options, asyncdispatch

import httpbeastfork

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

httpbeast_fork's People

Contributors

dom96 avatar thomastjdev avatar timotheecour avatar zedeus avatar kubo39 avatar iffy avatar bung87 avatar ajusa avatar bahm avatar hokamoto avatar ire4ever1190 avatar jasonprogrammer avatar pigmej avatar sthenic avatar xbello avatar inv2004 avatar metagn avatar

Stargazers

 avatar  avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.