This is a simple proof of concept of a HTTP server written in Go.
- Install Go
- Clone this repository with
git clone https://github.com/Arpan-206/my-http-server.git
- Run
./your_server.sh --directory /tmp/
to start the server
There are many routes you can connect to. Here are some examples:
- GET request to
http://localhost:4221/
will return a 200 status code without content. - GET request to
http://localhost:4221/echo/{some_text}
will return a 200 status code with the text you provided. - GET request to
http://localhost:4221/user_agent
will return a 200 status code with the user agent of the request. - GET request to
http://localhost:4221/files/{file_name}
will return a 200 status code with the content of the file you provided. - POST request to
http://localhost:4221/files/{file_name}
with a body will create a file with the content of the body and return a 200 status code.
To look around the code, you can open the app/server.go
file. This is where the server is defined and the routes are set up. Rest of the files are just helper files.