Browse Source

fixed typos, cleaned up

dependabot/npm_and_yarn/web/prismjs-1.21.0
Max Schmitt 8 years ago
parent
commit
1b4a9a1dbc
  1. 2
      .travis.yml
  2. 26
      README.md
  3. 52
      coverage.sh

2
.travis.yml

@ -5,4 +5,4 @@ before_install:
- go get github.com/mattn/goveralls
script:
- go test -v ./...
- $GOPATH/bin/goveralls -service=travis-ci
- goveralls -service=travis-ci

26
README.md

@ -9,17 +9,17 @@
- URL Shortening
- Visitor Counting
- Deletion URLs
- URL deletion
- Authorization System
- High Performance database with [bolt](https://github.com/boltdb/bolt)
- ShareX integration
- High performance database with [bolt](https://github.com/boltdb/bolt)
- [ShareX](https://github.com/ShareX/ShareX) integration
- Easy Docker Deployment
## Server Installation
### Standard
Since we don't provide prebuild binaries, you have to build it yourself. For that you need golang and git installed on your system.
Since we don't provide prebuild binaries, you have to build it yourself. For that you need Golang and Git installed on your system.
```bash
git clone https://github.com/maxibanki/golang-url-shortener # Clone repository
@ -30,21 +30,21 @@ go build # Build executable
```
### Docker Compose
- Only execute the [docker-compose.yml](docker-compose.yml) and adjust the enviroment variables to your needs.
Only execute the [docker-compose.yml](docker-compose.yml) and adjust the environment variables to your needs.
### Envirment Variables:
| Envirment Variable | Description | Default Value |
| Environment Variable | Description | Default Value |
| ------------------ | ----------- | ------------- |
| SHORTENER_DB_PATH | Relative or absolute path to the bolt DB | main.db |
| SHORTENER_LISTEN_ADDR | Adress to which the http server should listen to | :8080 |
| SHORTENER_LISTEN_ADDR | Address to which the http server should listen to | :8080 |
| SHORTENER_ID_LENGTH | Length of the random short URL id | 4 |
## Clients:
### [ShareX](https://github.com/ShareX/ShareX) Configuration
This URL Shortener has fully support with ShareX. To use it, just import the configuration to your ShareX. For that you need to open the `Destination settings` => `Other / Custom uploaders` => `Import` => `From Clipboard`.
This URL Shortener has fully support with ShareX. To use it, just import the configuration to your ShareX. For that you need to open the `Destination settings` => `Other / Custom uploaders` => `Import` => `From Clipboard` menu.
After you've done this, you need to set it as your standard URL Shortener. For that go back into your main menu => `Destinations` => `URL Shortener` => `Custom URL Shortener`.
@ -68,27 +68,27 @@ After you've done this, you need to set it as your standard URL Shortener. For t
#### `/api/v1/create` POST
Create is the handler for creatng entries, you need to provide only an URL. The responsive will always be JSON encoded and contain an URL with the short link.
Create is the handler for creating entries, you need to provide only an URL. The response will always be JSON encoded and contain an URL with the short link.
There is a mechamism integrated, that you can call this endpoint with the following techniques:
There is a mechanism integrated, that you can call this endpoint with the following techniques:
- application/json
- application/x-www-form-urlencoded
- multipart/form-data
In all cases only add the long URL as a field with the key `URL` and you will get the response with the short URL.
### `/api/v1/info` POST
#### `/api/v1/info` POST
This handler returns the information about an entry. This includes:
- Created At
- Last Visit
- Visit count
- Visitor counter
To use this, POST a JSON with the field `id` to the endpoint. It will return a JSON with the data.
## TODO
- Authentification
- Authorization
- Deletion
- Add Curl Examples
- Test docker-compose installation

52
coverage.sh

@ -1,52 +0,0 @@
#!/bin/sh
# Generate test coverage statistics for Go packages.
#
# Works around the fact that `go test -coverprofile` currently does not work
# with multiple packages, see https://code.google.com/p/go/issues/detail?id=6909
#
# Usage: script/coverage [--html|--coveralls]
#
# --html Additionally create HTML report and open it in browser
# --coveralls Push coverage statistics to coveralls.io
#
set -e
workdir=.cover
profile="$workdir/cover.out"
mode=count
generate_cover_data() {
rm -rf "$workdir"
mkdir "$workdir"
for pkg in "$@"; do
f="$workdir/$(echo $pkg | tr / -).cover"
go test -covermode="$mode" -coverprofile="$f" "$pkg"
done
echo "mode: $mode" >"$profile"
grep -h -v "^mode:" "$workdir"/*.cover >>"$profile"
}
show_cover_report() {
go tool cover -${1}="$profile"
}
push_to_coveralls() {
echo "Pushing coverage statistics to coveralls.io"
goveralls -coverprofile="$profile" -repotoken lhWzILT1WMRgrHXsEhauQOGsoby1nm7DR
}
generate_cover_data $(go list ./...)
show_cover_report func
case "$1" in
"")
;;
--html)
show_cover_report html ;;
--coveralls)
push_to_coveralls ;;
*)
echo >&2 "error: invalid option: $1"; exit 1 ;;
esac
Loading…
Cancel
Save