A server is a computer system capable of delivering web content to end users over the internet via a web browser. In this project we deliver the current date and time to the user using two golang packages net/http and gin.
This end point returns a message that has the current date and time as a JSON for simplicity and easier exchange of data between different technologies.
{"message": "2024-07-07 16:08"}
- Clone the Repository to a directory of your choice.
- Make sure you have go version 1.22.4 installed on your device.
- Open the directory in a code editor of your choice.
- Navigate to cmd/ginserver or cmd/httpserver directory
- Build the project using:
user@user-VirtualBox:~$ go build main.go
- Run the project using:
user@user-VirtualBox:~$ ./main
- Open a web browser of your choice.
- Use http://localhost:8090/datetime for http server or http://localhost:8080/datetime for gin server to perform a request.
- Shutdown the server using ctrl + c inside the terminal.
=== RUN TestClientCanHitAPI === RUN TestClientCanHitAPI/happy_path_-can_hit_the_api_and_return_date&time --- PASS: TestClientCanHitAPI (0.00s) --- PASS: TestClientCanHitAPI/happy_path-can_hit_the_api_and_return_date&time (0.00s) PASS ok github.com/codescalersinternships/DateTime-Server-Abdelrahman-Mahmoud/pkg/httpclient (cached) === RUN Test_GetDateTimeHandler === RUN Test_GetDateTimeHandler/happy_path-can_hit_the_api_and_return_date&time --- PASS: Test_GetDateTimeHandler (0.00s) --- PASS: Test_GetDateTimeHandler/happy_path-can_hit_the_api_and_return_date&_time (0.00s) PASS ok github.com/codescalersinternships/DateTime-Server-Abdelrahman-Mahmoud/pkg/httpserver (cached)