An example unit conversion service that provides a RESTful API for converting between units.
2.8K
This Docker image packages a lightweight, serverless RESTful API written in GoLang for converting between Celsius and Fahrenheit temperature units. It's designed for practicing deployments in serverless environments like Kubernetes, AWS Lambda, Google Cloud Functions, and Azure Functions.
docker pull nikfarjam/unit-converter-api-lightweight:tagname
docker run -it -p 9090:9090 nikfarjam/unit-converter-api-lightweight:tagname
This will start the API server on port 9090.
Converts temperature between Celsius and Fahrenheit.
Request Body (JSON):
Returns the current version of the API.
Response: Plain text version string (e.g., "v1.1.0")
Example:
curl http://localhost:9090/version
Convert Celsius to Fahrenheit:
curl -d '{ "value": 25, "from": "CELSIUS", "to": "FAHRENHEIT" }' http://localhost:9090/converter
Convert Fahrenheit to Celsius:
curl -d '{ "value": 77, "from": "FAHRENHEIT", "to": "CELSIUS" }' http://localhost:9090/converter
Invalid Unit (returns error):
Convert Celsius to Fahrenheit:
curl -d '{ "value": 25, "from": "CELSIUS", "to": "FAHRENHEIT" }' http://localhost:9090/converter
Convert Fahrenheit to Celsius:
curl -d '{ "value": 77, "from": "FAHRENHEIT", "to": "CELSIUS" }' http://localhost:9090/converter
Invalid Unit (returns error):
curl -v -d '{ "value": 20, "from": "Kelvin", "to": "Celsius" }' http://localhost:9090/converter
from or to is not "CELSIUS" or "FAHRENHEIT", the API returns HTTP 400 with an error message.Source Code: https://github.com/nikfarjam/unit-convertor-go
License: Apache-2.0
Content type
Image
Digest
sha256:3c92ca380…
Size
8.5 MB
Last updated
8 months ago
docker pull nikfarjam/unit-converter-api-lightweight