Skip to content

hadrienblanc/boxsize-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BoxSize Service

(Docker - Makefile - golang)

BoxSize is a golang micro-service to compute the volume contains inside a box.

It accepts tree integers as parameters : height, width, length.

Then the service returns two strings with two informations : The box size in cm³ and the corresponding box capacity in liters.

If 42 is a number somewhere, we raise an error because it's a special number.

Installation

You can build and run the service inside a Docker. The makefile has a docker-build and a docker-run commands.

$> make docker-build
$> make docker-run
+ exec app
BoxSize Server will run on port 3000

If you prefer avoid docker, feel free to run :

make run

Standard use-cases

Normal case

Query :

curl -XPOST -d '{"height": 1, "width": 3, "length": 2}' localhost:3000

Answer :

{"results":["The box volume is 6 cm³","It's also 0 liters."]}

Error case <value 42>

Query :

curl -XPOST -d '{"height": 1, "width": 42, "length": 2}' localhost:3000

Answer :

The box mensuration can't have a 42 number

Error case with bad keys

Query :

curl -XPOST -d '{"bad_stuff": 123}' localhost:3000

Answer :

An error occured while decoding the json format request.

About

A dockerized golang micro-service to compute the volume contains inside a box

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors