Browse Source

- Removed that the IP of the creator will be shown in the info request

- improved README.md
dependabot/npm_and_yarn/web/prismjs-1.21.0
Max Schmitt 8 years ago
parent
commit
3ec2257880
  1. 48
      README.md
  2. 9
      handlers/handlers.go
  3. 2
      store/store.go

48
README.md

@ -2,26 +2,38 @@
## Features:
- URL Shortening with visiter counting
- Delete an entry
- Authorization
- Storing using BoltDB
- Easy ShareX integration
- Selfhosted
- URL Shortening with visitor counting
- Deletion URLs
- Authorization System
- High Performance database with [bolt](https://github.com/boltdb/bolt)
- ShareX integration
- Easy Docker Deployment
## Installation
## Server Installation
### Standard
```bash
git clone https://github.com/maxibanki/golang-url-shortener
go get -v ./...
go run -v main.go
go build
./golang-url-shortener
```
### 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 enviroment variables to your needs.
## [ShareX](https://github.com/ShareX/ShareX) Configuration
### Envirment Variables:
| Envirment 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_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`.
@ -41,11 +53,15 @@ After you've done this, you need to set it as your standard URL Shortener. For t
}
```
### Curl
## TODO
## TODOs
- github publishing
- authentification
- deletion
- ShareX example
- Authentification
- Deletion
- Github publishing
- Add shields:
- downloads
- travis
- godoc
- license

9
handlers/handlers.go

@ -152,13 +152,18 @@ func (h *Handler) handleInfo(w http.ResponseWriter, r *http.Request, p httproute
http.Error(w, "no ID provided", http.StatusBadRequest)
return
}
raw, err := h.store.GetEntryByIDRaw(req.ID)
entry, err := h.store.GetEntryByID(req.ID)
if err != nil {
http.Error(w, err.Error(), http.StatusNotFound)
return
}
entry.RemoteAddr = ""
w.Header().Add("Content-Type", "application/json")
w.Write(raw)
err = json.NewEncoder(w).Encode(entry)
if err != nil {
http.Error(w, err.Error(), http.StatusNotFound)
return
}
}
// handleAccess handles the access for incoming requests

2
store/store.go

@ -21,7 +21,7 @@ type Store struct {
type Entry struct {
URL string
VisitCount int
RemoteAddr string
RemoteAddr string `json:",omitempty"`
CreatedOn time.Time
LastVisit time.Time
}

Loading…
Cancel
Save