Skip to content

ungsophy/http-server

Repository files navigation

progress-banner

Simple HTTP Server 1.1

This is a code crafters challenge to build a simple HTTP server 1.1 in Go. Some implemented features are:

  • Multiplexer
  • Path variables
  • Concurrent connections
  • Persisten connections
  • Gzip compression

To start the program:

$ go run main.go --directory /path/to/tmp # --directory is where files are written to and read from

To run tests:

$ make test

Endpoints

GET /
Returns a 200 status code

GET /user-agent
Returns client user agent

GET /echo/{str}
Returns str

GET /files/{filename}
Read file from --directory

POST /files/{filename}
Create a new file with content from the request body in --directory

Examples

Call the echo endpoint and gzip the response

$ curl -H "Accept-Encoding: gzip" http://localhost:4221/echo/hello | gunzip -c

Create a new file

$ curl --data "hello" -H "Content-Type: application/octet-stream" http://localhost:4221/files/hello

Fetch content of a file

$ curl http://localhost:4221/files/hello

About

A code crafters challenge to build a simple HTTP server 1.1 in Go

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors