This is a simple HTTP server and command line client written in go used to store plain text files.
The code is divided into two parts. Both of these parts need to be executed separately for the code to work. These two parts are
This is the backend of the program. This handles the db and the logic for the file storing system. It has a http server which listens to port 2021. This server is connected to a MySQl database
CLI Client is a program which acts as a mediator between the server and user. Instead of hitting the API directly, the client helps in making this process a streamlined process. The client supports the command for which API routes are defined.
- MySQL database
Note: You will need to create a local MySQL database.
- Create an .env file. Copy .env.sample and replace the placeholder which correct credentials
- Install the dependencies by running the following command
go mod download
- Build the server
go build main.go
- Run the server
./main
- Open a new terminal window and go to
clientdirectory
cd client
- Build the client
go build client.go
- Run the client
./client
The current code has a large scope of improvement. Possible improvement are.
- Authentication and authorization Currently, any one with the URL of server can access it. Authentication and authorization will help in this.
- Support for more file formats The current server supports only txt files. It can be improved to support storing of other file formats.
- Size limit Currently, size limit is very less. It can be improved to send continous stream of packets for large files.
GPL-3.0 license
There is test each for client and main.
To run tests for main. Enter the following commands
go build main_test.go
go test .
Similarly, to run tests for client. Enter the following commands
cd client
go build client_test.go
go test .
