stateless_api

command module
v0.0.0-...-f07a54b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 6, 2024 License: MIT Imports: 11 Imported by: 0

README

StatelessAPI; Calculator service

Endpoints
add

Command: curl -d '{"num1":2, "num2":3}' http://localhost:8080/add/
Returns:

Calculation: 2 + 3
Answer: 5
subtract

Command: curl -d '{"num1":2, "num2":3}' http://localhost:8080/subtract/
Returns:

Calculation: 2 - 3
Answer: -1
divide

curl -d '{"num1":2, "num2":3}' http://localhost:8080/divide/
Returns:

Calculation: 2 / 3
Answer: 0.6666666666666666
multiply

curl -d '{"num1":2, "num2":3}' http://localhost:8080/multiply/
Returns:

Calculation: 2 x 3
Answer: 6

ToDo:

  • Add in rate limiter to prevent misuse of the API
  • Add in a database to keep track of all of the calculations that have taken place
  • Add in a middleware that adds a request ID to the http.Request object.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL