From e45d710df4c4b7aae1bc129ebbdacf5a0332c834 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Sun, 29 Oct 2017 23:27:03 +0100 Subject: [PATCH] fixed naming to URL Shortener --- README.md | 30 ++++++++++++++++++++++++++---- docker-compose.yml | 2 +- handlers/handlers.go | 2 +- handlers/handlers_test.go | 3 +-- main.go | 16 ++++++++-------- 5 files changed, 37 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 67b60c4..f0c7071 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,13 @@ -# Golang URL Shorter using BoltDB +# Golang URL Shortener using BoltDB ## Features: -- URL Shorting with visit counting -- delete a URL -- Authorization via tokens +- URL Shortening with visiter counting +- Delete an entry +- Authorization - Storing using BoltDB +- Easy ShareX integration +- Selfhosted ## Installation @@ -21,6 +23,26 @@ Only execute the [docker-compose.yml](docker-compose.yml) and adjust the envirom ## [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`. + +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`. + +```json +{ + "Name": "Golang URL Shortener", + "DestinationType": "URLShortener", + "RequestType": "POST", + "RequestURL": "http://127.0.0.1:8080/api/v1/create", + "Arguments": { + "URL": "$input$" + }, + "ResponseType": "Text", + "URL": "$json:URL$" +} +``` + + + ## TODOs - github publishing diff --git a/docker-compose.yml b/docker-compose.yml index a3d9013..e14188b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -shorter: +shortener: image: golang restart: always command: ./run.sh diff --git a/handlers/handlers.go b/handlers/handlers.go index 3103e7c..7e1d622 100644 --- a/handlers/handlers.go +++ b/handlers/handlers.go @@ -8,7 +8,7 @@ import ( "strings" "github.com/julienschmidt/httprouter" - "github.com/maxibanki/golang-url-shorter/store" + "github.com/maxibanki/golang-url-shortener/store" ) // Handler holds the funcs and attributes for the diff --git a/handlers/handlers_test.go b/handlers/handlers_test.go index 2b4c062..27ef056 100644 --- a/handlers/handlers_test.go +++ b/handlers/handlers_test.go @@ -12,12 +12,11 @@ import ( "strings" "testing" - "github.com/maxibanki/golang-url-shorter/store" + "github.com/maxibanki/golang-url-shortener/store" "github.com/pkg/errors" ) const ( - baseURL = "http://myshorter" testingDBName = "main.db" testURL = "https://www.google.de/" ) diff --git a/main.go b/main.go index 3bd9ca7..9cb4bf0 100644 --- a/main.go +++ b/main.go @@ -6,22 +6,22 @@ import ( "os/signal" "strconv" - "github.com/maxibanki/golang-url-shorter/handlers" - "github.com/maxibanki/golang-url-shorter/store" + "github.com/maxibanki/golang-url-shortener/handlers" + "github.com/maxibanki/golang-url-shortener/store" ) func main() { dbPath := "main.db" listenAddr := ":8080" idLength := uint(4) - if os.Getenv("SHORTER_DB_PATH") != "" { - dbPath = os.Getenv("SHORTER_DB_PATH") + if os.Getenv("SHORTENER_DB_PATH") != "" { + dbPath = os.Getenv("SHORTENER_DB_PATH") } - if os.Getenv("SHORTER_LISTEN_ADDR") != "" { - listenAddr = os.Getenv("SHORTER_LISTEN_ADDR") + if os.Getenv("SHORTENER_LISTEN_ADDR") != "" { + listenAddr = os.Getenv("SHORTENER_LISTEN_ADDR") } - if os.Getenv("SHORTER_ID_LENGTH") != "" { - length, err := strconv.ParseUint(os.Getenv("SHORTER_ID_LENGTH"), 10, 32) + if os.Getenv("SHORTENER_ID_LENGTH") != "" { + length, err := strconv.ParseUint(os.Getenv("SHORTENER_ID_LENGTH"), 10, 32) if err != nil { log.Fatalf("could not convert ID length into an uint: %v", err) }