This is my second (but first test-driven attempt) at writing an HTTP server in Haskell. It is intended as both an exploration of Haskell and the HTTP protocol and is thus inherently incomplete as my knowledge of both is also incomplete. As I better understand each element, this codebase will continue to improve. I actually haven't read the HTTP/1.1 specification I am presently implementing.
I am writing this by adding thin, vertical slices of atomic functionality. This allows the product to be useful near immediately. At present, I have written two demonstration routes. The first can reach out to the internet via the client that was built in tandem with this server as a testing utility. The second will output the contents of any file on the computer on which it is running. Take care! Both routes will respond to any HTTP verb.
I hope you enjoy reading and modifying this as much as I have enjoyed creating it.
- Install Stack
- Run
stack build --ghc-options="-Wall -Werror"inside the project directory - Run
stack exec server-exeinside the project directory - Your server is now listening on port 8080.
- Add more routes in the
main.hsfile.
* I'm not certain that I haven't missed something
- Install Stack
- Run
stack test
- HTTP Client
- GET
- POST
- PUT
- DELETE
- HTTP Server
- GET
- POST
- PUT
- DELETE
- Headers
- Client request
- Client response
- Server request
- Server response
- JSON writer
- JSON parser
- Lightweight document store
- HTML templating DSL
- Functional dependency injection
- Route matching based on passed params or headers
- HTTPS