Skip to content

✨ A simple HTTP server for calculating averages, sums, and counts of numbers (even, odd, or all) with a RESTful API.

License

Notifications You must be signed in to change notification settings

Martande8055/go-redhat

Repository files navigation

Create Go App

Go version License issues
Github Stars Github Forks

Average Calculation API

A simple HTTP server for calculating averages, sums, and counts of numbers (even, odd, or all) with a RESTful API.

⚡️ Quick Start

First, ensure you have Go installed. Version 1.22.7 or higher is required.

Installation

Use the following command to clone and install the project:

git clone https://github.com/Martande8055/go-redhat.git
cd go-redhat/
go mod tidy
go build -o main main.go

To run the server:

./main

The server will start on port 3100.

Usage You can send POST requests to the following endpoints to calculate averages:

  • For Even Numbers: /even

  • For Odd Numbers: /odd

  • For All Numbers: /evenodd

Example Request Here's how to make a request using curl:

curl -X POST http://localhost:3100/even -H "Content-Type: application/json" -d '{"op": "avg", "nums": [2, 4, 6, 8]}'

⚙️ API Endpoints

POST /even

Calculate the average, sum, or count of even numbers.

You can Specify different Operations as follows:

  • avg for average

  • sum for sum

  • count for count

Json Input Example:

{
  "op": "avg",
  "nums": [2, 4, 6, 8]
}

📝 Testing

Run the unit tests with:

go test ./... -v

🚚 Docker Support

To run the application in a Docker container:

  1. Build the image:
podman build -t go_average_app .
  1. Run the container:
podman run -p 3100:3100 go_average_app

⭐️ Project Assistance

If you find this project helpful, please give it a star on GitHub!

⚠️ License

The Average Calculation API is free and open-source software licensed under the MIT License.

About

✨ A simple HTTP server for calculating averages, sums, and counts of numbers (even, odd, or all) with a RESTful API.

Resources

License

Stars

Watchers

Forks

Packages

No packages published