A proof of concept implementation of a clean-architecture (see uncle bob's clean architecture description) with an image caching service as the main use-case.
- The domain is the thumbnail.
- The usecase is the image resizing and storing part.
- The interface of the system is a webservice and storage abstraction.
- The infrastructure implements the concrete resizer, storage etc systems.
install the dependencies, build the binary and start it
$ dep ensure
$ go build
$ ./tics
To set the port, export the environment variable "TICS_PORT"
$ export TICS_PORT="8888"
$ ./tics # will start listening on port 8888
The tics service is using a base64 encoded url including width and height resizing information:
- url : https://www.wikipedia.org/portal/wikipedia.org/assets/img/Wikipedia-logo-v2.png
- width: 20
- height: 20
should be converted into the following pattern:<url>?w=<width>&h=<height>
. Finally run all this through a base64 encoder and you are good to go:
- https://www.wikipedia.org/portal/wikipedia.org/assets/img/Wikipedia-logo-v2.png?w=20&h=20
- aHR0cHM6Ly93d3cud2lraXBlZGlhLm9yZy9wb3J0YWwvd2lraXBlZGlhLm9yZy9hc3NldHMvaW1nL1dpa2lwZWRpYS1sb2dvLXYyLnBuZz93PTIwJmg9MjA=
Now you have a nice base64 encoded image path and some resizing information. Call the service with
localhost:8080/?i=<base64encoded...>
- localhost:8080/?i=aHR0cHM6Ly93d3cud2lraXBlZGlhLm9yZy9wb3J0YWwvd2lraXBlZGlhLm9yZy9hc3NldHMvaW1nL1dpa2lwZWRpYS1sb2dvLXYyLnBuZz93PTIwJmg9MjA=
and you get a nice small wikipedia image.
cd /path/to/tics
and then go test ./...
.
This project is licensed under MIT license. Use at your own risk and will!