https://github.com/ankurgel/reducto
Shortens URLs with a simple spell.
https://github.com/ankurgel/reducto
Last synced: 3 days ago
JSON representation
Shortens URLs with a simple spell.
- Host: GitHub
- URL: https://github.com/ankurgel/reducto
- Owner: AnkurGel
- Created: 2021-04-12T04:44:05.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2021-04-17T16:40:49.000Z (about 4 years ago)
- Last Synced: 2023-03-23T03:47:35.813Z (about 2 years ago)
- Language: Go
- Homepage:
- Size: 59.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Reducto
=======
A simple but performant and distributed URL shortener.### API:
___Shorten URL___----
Shortens provided URL and returns json data* **URL**
/api/v1/shorten
* **Method:**
`POST`
* **Data Params**
**Required:**
`url=[string]`
**Optional:**
`custom=[string]`* **Success Response:**
* **Code:** 201 Created
**Content:** `{"longUrl":"http://foobar.com","shortUrl":"http://localhost:8081/FPvYGy"}`* **Error Response:**
* **Code:** 422 Unprocessable Entity
**Content:** `{ error : "User doesn't exist" }`OR
* **Code:** 422 Unprocessable Entity
**Content:** `{"error":"URLValidationError: URL Domain is banned."}`---
___Get Long URL___----
Retrieves long URL and redirects* **URL**
/:shortUrl
* **Method:**
`GET`
* **Path Params**
**Required:**
`shortUrl=[string]`* **Success Response:**
* **Code:** 302 Moved Permanently
**Content:** `Moved Permanently.`* **Error Response:**
* **Code:** 404 Not Found
**Content:** `{"error":"Error in getSlug for f00bar: record not found"}`OR
* **Code:** 422 Unprocessable Entity
**Content:** `{"error":"URLValidationError: URL Domain is banned."}`### Installation
#### Via Docker:
```
git clone [email protected]:AnkurGel/reducto.git
docker-compose up
$> curl --location --request POST 'http://localhost:8080/api/v1/shorten' --form 'url="https://github.com/AnkurGel/reducto"'
```### Development
* `cp config.yml.sample config.yml`
* Edit `config.yml`
* Create relevant database
* Add banned hosts in the redis manually like:
`SADD urlBannedSet bit.ly tinurl.com tiny.one t.co rotf.lol goo.gl fb.me`
* Run keygen: `REDUCTO_CONFIG_PATH=config.yml go run cmd/reducto-keygen/main.go`
* Run server: `REDUCTO_CONFIG_PATH=config.yml go run cmd/reducto-server/main.go`