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 fromTo run tests:
$ make test
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
Call the echo endpoint and gzip the response
$ curl -H "Accept-Encoding: gzip" http://localhost:4221/echo/hello | gunzip -cCreate a new file
$ curl --data "hello" -H "Content-Type: application/octet-stream" http://localhost:4221/files/helloFetch content of a file
$ curl http://localhost:4221/files/hello