- generate mocks:
go generate ./... - execute tests:
go test ./... - run application (port 8080):
go run cmd/main.go
Service supports only two types of images: jpeg and png.
API:
-
Upload image:
user and image name need to be specified in query parameters when apploading an image. Example below uploads png image from fileimage.pngto the server for userjohnand image is stored under namemario. It is aPOSTmethod.curl -XPOST --data-binary "@./image.png" http://localhost:8080/images\?user\="john"\&name\="mario" -
List images:
Images are listed withGETmethod, whennamequery parameter is not set:curl http://localhost:8080/images\?user\=johnresponse:
{ "mario": { "large": "http://localhost:8080/images?user=john\&name=mario\&scale=large", "medium": "http://localhost:8080/images?user=john\&name=mario\&scale=medium", "small": "http://localhost:8080/images?user=john\&name=mario\&scale=small" }There are tree scales available:
small,medium, andlarge. (configured inmain.go:) ) -
Query/Scale and image
curl http://localhost:8080/images\?user\="john"\&name\="mario"\&scale\="small" --output result.jpeg