golink
A simple url shortening web server.
build
Executable: go build -o golink ./cmd/golink
Docker: docker build .
run
local
go run ./cmd/golink
or use the executable ./golink
docker
# exposes the server on 8082
docker run -d -p 8082:8082 almartino/golink:latest
# you can also mount the db directory for persistence:
$ docker run -d -v LOCAL:/db -p 8082:8082 almartino/golink:latest
# or change the logging level:
$ docker run -d -e LOG_LEVEL=TRACE -p 8082:8082 almartino/golink:latest
Specifications
Golink can run as executable or in a docker container and exposes on the port 8082
the following endpoints:
NAME |
METHOD |
PATH |
RESULT |
Content-Type |
List |
GET |
/api/urls |
ShortURL[ ] |
application/json |
Create |
POST |
/api/urls |
ShortURL |
application/json |
GetSingle |
GET |
/api/urls/:url |
ShortURL |
application/json |
Delete |
DELETE |
/api/urls/:url |
ShortURL |
application/json |
Redirect |
GET |
/:url |
- |
- |
Docs |
GET |
/api/docs/ |
SwaggerUI |
- |
more info about exposed endpoints on api file or visiting the url $SERVER_URL/api/docs/
please pay attention on the last /
######ShortURL object structure
{
"original": "https://google.com",
"path": "MA==",
"visits": 12
}
configuration
some environment variables can be set before app startup:
- LOG_LEVEL (to change the default application log level which is DEBUG)
- DOCS_PATH (to change the default swagger-ui directory which is web)