The Area Calculator API provides a simple and efficient way to compute the area of various geometric shapes, including square, circles, rectangles, triangles, and more.
credits: shutterstock.com- Calculate the area of common shapes: Circle, Rectangle, Triangle, and Square.
- Fast and efficient calculations.
- Formatted response
- Efficient error handling
Before you begin, ensure you have met the following requirements:
-
Go: You need to have Go v1.21+ installed on your machine. Download it from the official Go website.
To check if Go is installed, run:
go version
To get started with the Area Calculator, follow these steps:
-
Clone the repository:
git clone https://github.com/kunalmemane/AreaCalculator.git cd AreaCalculator
-
Build the application:
go build -o ./bin/main ./cmd/main.go
-
Run the application:
./bin/main
The API will be available at http://localhost:8080/
- Circle: Requires the radius.
- Rectangle: Requires the length and breadth.
- Triangle: Requires the sideA, sideB and sideC.
- Square: Requires the side length.
Once the Application is running, you can make HTTP requests to calculate areas of supported shapes using the /getArea
endpoint.
POST /getArea
To calculate the area of multiple shapes, use the following curl command:
-
Triangle
curl -X POST http://localhost:8080/getArea -d '{ "shape":"Triangle", "sideB":20, "sideA": 10, "sideC":15 }' -H "Content-Type: application/json"
-
To test the application run below commands
make test or go test ./...
This project includes a Makefile
to simplify common tasks. You can use the following commands:
make build
: Compile the project.make run
: Build and run the application.make test
: Run the tests for the project.make clean
: Remove build artifacts.make all
: To do clean, test, build, run tasks in one command.make podman-build
: Build Application Image using Podman.make podman-run
: Run Application Container Image.make podman-push
: Push Application Image to quay.io - podman login required.make oc-deploy
: Deploy application to openshift using docker strategy - oc login required.make oc-delete
: Delete all resources in openshift project - oc login required.
Contributions are welcome! Please feel free to submit a Pull Request or open an Issue for discussion.
- Fork the repository.
- Create your feature branch (git checkout -b feature/AmazingFeature).
- Commit your changes (git commit -m 'Add some AmazingFeature').
- Push to the branch (git push origin feature/AmazingFeature).
- Open a Pull Request.
This project is licensed under the MIT License. See the LICENSE file for details.