Create and document a small web service exposing URL shortening functions.
One should be able to create, read, and delete shortened URLs.
The API functions will be exposed under the /api
path while accessing a shortened URL at the root
level will cause redirection to the shortened URL.
- Code in Golang (unless differently agreed)
- It's ok to forget about permissions (everyone can do anything) for the sake of the exercise.
- Documentation will be publicly exposed via a specific service URL.
- Code will be tested to a reasonable extent
- You're free to choose any storage mechanism you wish
We expect to be able to run the application locally just following the project README documentation. Do not assume the host running your service will meet any requirement (no storage engine is pre-installed).
- Implement a counter of the shortened URL redirects
- Add an API endpoint to read shortened URL redirects count
- Assume you always start wrong (being ill informed on the beginning of any project is the only thing that is right), makes starting assumptions always questionable
- Assume there will always be change (make it easy to be able to change things and revise decisions taken in the beginning)
In short it has as a prerequisite:
- A machine running Docker Daemon and Docker Compose
# build and run services:
docker-compose up --build
# stop and remove services:
docker-compose down
or for already existing containers
# start services:
docker-compose start
# stop services:
docker-compose stop
Visit http://localhost:8080 for a Demo-Frontend.
The statistics for a short-link can be requested via http://localhost:8080/shortUrlStats/"put_url-Code_here"
The documentation for the Go-App is available under http://localhost:6060/pkg/urlShortener/.
Specifically for the REST-API follow the link http://localhost:6060/pkg/urlShortener/urlHandler/#pkg-constants.
Prerequisite:
-
A cloned Repo:
git clone https://github.com/FranzBranntvino/urlsGoShort.git
-
A machine with Docker Daemon running and VSCode including Remote Plugins installed.
See the .devcontainer/README.md for more detailed information on this subject.
NOTE: It might be that in the current Dev-Setup some of the Tests are failing if the DB-Service are not running, hence the DB-client is unable to connect to the DB.
-
Some Status Codes of the response are not used right: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes and https://cheatography.com/jp153/cheat-sheets/http-status-codes-golang/
- Post http://localhost:8080/createShortUrl:
200
response, should become:201
(Created) - Post http://localhost:8080/shortUrlDelete:
302
response -> missing Location header, should become:200
(OK) or204
(No Content)
- Post http://localhost:8080/createShortUrl:
-
Improve on REST API, e.g. Naming, Documentation, Functionality,
GET
,POST
andDELETE
usage, return JSON -
Separate concerns for Unit and Integration tests: provide mocks and stubs for the unit tests to work sufficiently and independent from other modules (DB Service)
-
Default Handling for undefined routes
-
Implement graceful stopping of http-Server
-
Implement graceful stopping of DB-client
-
Build in scalability for the services
-
Make Mega-Links work: e.g. long (>2000 chars) full version of https://godbolt.org/z/9TeK9hYh9
- reference: https://bitly.com/ does not work with it either and it is supposing this seems to be an invalid URL
-
Handling of local links (e.g. local files), despite they lead to security violations: file:///home/vagrant/urlsGoShort/.devcontainer/README.md
- Second besides the formatting issue is, that this is a Security issue in some Browsers:
Security Error: Content at http://localhost:8080/ may not load or link to file:///home/vagrant/urlsGoShort/.devcontainer/README.md.
- reference: https://bitly.com/ does not work with it either and it is supposing this seems to be an invalid URL
- Second besides the formatting issue is, that this is a Security issue in some Browsers:
-
Improve on Frontend formatting e.g. representation of very long links, Error Responses/Handling/Messaging