Coder Social home page Coder Social logo

reducto's Introduction

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: <a href="http://foobar.com">Moved Permanently</a>.
  • 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

reducto's People

Contributors

ankurgel avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.