Skip to content

A simple HTTP REST API server in different languages

Notifications You must be signed in to change notification settings

begoon/http-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HTTP server in different languages

Problem statement

The server listens on localhost:8000 and exposes /version endpoint.

The /version endpoint returns a RESTful JSON response with the "version" fields. The payload should be serialized to JSON from a struct or class, not printed as a simple string.

Other routes, root included, should return 404.

When the server runs, it should respond to curl http://localhost:8000/version or in the web browser.

Used compilers and interpreters

language version framwork source run command
zig 0.14.0 httpz main.zig make zig
rustc 1.82.0 warp main.rs make rust
swift 6.0 vapor main.swift make swift
go 1.23 - main.go make go
v 0.4.8 - main.v make v
crystal 1.14.0 - main.cr make crystal
assember arm64 macos/libc main.s make arm64
d/ldc 1.40 vibe main.d make d
ruby 3.3.6 sinatra main.rb make ruby
dart 3.5.4 - main.dart make dart
deno 2.0.6 - main-deno.ts make deno
bun 1.1.34 - main-bun.ts make bun
node 23.1.0 - main.js make node
php 8.3.13 - main.php make php
python 3.13 fastapi main.py make python
pascal/fpc 3.2.2 - main.pas make fpc
lua 5.4.7 copas main.lua make lua
csharp/dotnet 9.0.0 - main.cs make cs
perl 5.34.1 mojolicious main.pl make perl

All implementations above are tested on macOS 15.1 Sequoia.

Run client

make q or curl -q http://localhost:8000/version.

Contributions

C# version is rewritten by @neon-sunset

Swift version is rewritten by @Frizlab

arm64 assembly version is based on @dmtrKovalenko's macos-assembly-http-server

About

A simple HTTP REST API server in different languages

Resources

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •