Browse Source

fixed naming to URL Shortener

dependabot/npm_and_yarn/web/prismjs-1.21.0
Max Schmitt 8 years ago
parent
commit
e45d710df4
  1. 30
      README.md
  2. 2
      docker-compose.yml
  3. 2
      handlers/handlers.go
  4. 3
      handlers/handlers_test.go
  5. 16
      main.go

30
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

2
docker-compose.yml

@ -1,4 +1,4 @@
shorter:
shortener:
image: golang
restart: always
command: ./run.sh

2
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

3
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/"
)

16
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)
}

Loading…
Cancel
Save