Skip to content

prashantrahul141/taurl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Fast url shortner written entirely in go.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published