This is a proxy that can be used in front of a Shlink service to make sure that only valid requests and espacially valid long links are sent to the Shlink. If a link is valid, it gets proxied to the Shlink. Otherwise, an error is returned.
Valid means in our PrioBike-context that the long link represents a shortcut-sharing-link consisting of a base64 encoded json shortcut object.
This service is only useful when used in combination with a Shlink service. It is not a standalone service.
Run locally using Docker:
docker-compose up
Configuration is done via environment variables. The following environment variables are available:
PROXY_TARGET
- The URL of the Shlink serviceLOG_LEVEL
- Differentiates betweendebug
or notdebug
log level
Run tests:
go test
This service mirrors the Shlink API. It is a subset of the Shlink API. The following endpoints are supported and get validated by this service:
- POST /rest/v3/short-urls - Create a new short URL
- GET /rest/v3/short-urls/{shortCode} - Get a short URL by its short code
Every other endpoint is not supported and will be invalid by default.
Should not work:
curl -X POST --header "X-Api-Key: secret" -H "Content-Type: application/json" -d @example_long_link_base64_invalid.json http://localhost/rest/v3/short-urls
Should work:
curl -X POST --header "X-Api-Key: secret" -H "Content-Type: application/json" -d @example_long_link_shortcut_location.json http://localhost/rest/v3/short-urls
Should not work:
curl -X GET --header "X-Api-Key: secret" -H "Content-Type: application/json" http://localhost/rest/v3/short-urls
Should work (if short link exists):
curl -X GET --header "X-Api-Key: secret" -H "Content-Type: application/json" http://localhost/rest/v3/short-urls/segrs4
We highly encourage you to open an issue or a pull request. You can also use our repository freely with the MIT
license.
Every service runs through testing before it is deployed in our release setup. Read more in our PrioBike deployment readme to understand how specific branches/tags are deployed.
Help us improve this documentation. If you have any problems or unclarities, feel free to open an issue.