Skip to content
A simple HTTP server for static websites written from scratch with thread pools.
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.


Type Name Latest commit message Commit time
Failed to load latest commit information.


A simple HTTP server for static websites written from scratch with thread pools.


I decided to write this very simple HTTP server from scratch without using any external packages or the core http library just to learn Go.


The library

The server doesn't need any external packages, just go get this repo and you are ready to go.

go get

A Simple HTTP server executable

go get


The Library

Using the library is very simple:

  server := servgo.NewServer(address, numberOfWorkers, maxQueuedConnecions)
  err := server.Run()

and the handler is a function with the following signature:

  func handleGetRequest(req servgo.Request) servgo.Response

You can check the executable's source code for an example:

The executable

$ servgo -h
Usage of ./servgo
-addr=":8080": The port to which the server will listen
-max-queued=1024: [Optional] The maximum number of connections that can be queued in the server
-num-workers=2: [Optional] Number of workers serving the requests
-root-dir="nil": [Required] The root dir for serving the files

$ servgo --root-dir example # Will start a server listening to port 8080 and serving files from the example directory

Notes On the Executable

  • The server currently supports only GET and HEAD requests.
  • The server spawns --num-workers workers to serve the incoming requests.
  • If a file is not specified in the request path index.html is served.
  • Server logs are printed to stdout, if you want to log them to a file you can pipe them.
You can’t perform that action at this time.