Giter Club home page Giter Club logo

taurl's Introduction

Taurl

Fast url shortner written entirely in Go using the gin framework.

Provided routes:

Retrives an existing shortend url.

GET /api/get (first reads the cache, then the db.)
Parameters
name type data type description
Url required String shortend url
Responses
http code content-type response
200 application/json Url body
400 application/json {"message":"Reason"}
404 application/json {"message":"Url was not found."}
Example cURL
 curl -X GET -H "Content-Type: application/json" http://localhost:3000/api/get?Url=http://localhost:3000/hash
GET /api/get_from_id (first reads the cache, then the db, but uses unique id of a shortend url.)
Parameters
name type data type description
unique_id required String shortend url's id
Responses
http code content-type response
200 application/json Url body
400 application/json {"message":"Reason"}
404 application/json {"message":"Url was not found."}
Example cURL
 curl -X GET -H "Content-Type: application/json" http://localhost:3000/api/get_from_id?Url=http://localhost:3000/hash

Sets a new shortend url and returns it.

POST /api/set (Creates and stores a new shortend url.)
Parameters
name type data type description
Url required String Original url
Responses
http code content-type response
201 application/json Url body
400 application/json {"message":"Reason"}
500 application/json {"message":"Failed to set db."}
Example cURL
 curl -X POST -H "Content-Type: application/json" --data '{"Url":"https://example.com"}'  http://localhost:3000/api/set

Building

The program expects these environment variables :

# defaults to 3000
PORT=3000

# defaults to http://localhost:3000
# this is what you would set as your base domain.
BASE_URL="http://localhost:3000"

# optionally you can provide GIN_MODE to get or remove log messages
# from the gin framework.
# defaults to debug
GIN_MODE="debug" # release, debug

clone and run using go cli.

git clone --depth 1 https://github.com/prashantrahul141/taurl && cd taurl && go run .

One Two

taurl's People

Contributors

prashantrahul141 avatar

Watchers

 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.