Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/minaandrawos/GoURLLinkShortnerAPI
A URL Link shortner API code written in Go
https://github.com/minaandrawos/GoURLLinkShortnerAPI
Last synced: 3 months ago
JSON representation
A URL Link shortner API code written in Go
- Host: GitHub
- URL: https://github.com/minaandrawos/GoURLLinkShortnerAPI
- Owner: minaandrawos
- Created: 2015-08-28T05:08:29.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-09-05T19:17:16.000Z (about 9 years ago)
- Last Synced: 2024-03-09T20:43:23.130Z (8 months ago)
- Language: Go
- Size: 188 KB
- Stars: 39
- Watchers: 4
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Go URL Link Shortener API
Full tutorial could be found at http://www.minaandrawos.com/2015/09/05/link-shortener-golang-web-service-tutorial-mongodb/
A URL Link shortener API code written in Go. The code is provided as-is, the code is for education purposes on how to write an efficient REST API in Go as well as some best practices for interfacing with Mongodb from Go.
The purpose of the API is to shorten url links via a REST HTTP request.
Once the code is built and running, to create a short url to a long url mapping, send a POST request to http://localhost:5100/Create, the POST request should include the shortUrl and the longUrl as follows:
{'shorturl':'cosmosfading','longurl':'https://cosmosmagazine.com/space/universe-slowly-fading-away'}You could then consume a shorturl by issuing a GET request to http://localhost:5100/shorturl
The program makes use of the Gorilla web toolkit mux library (http://www.gorillatoolkit.org/pkg/mux) for routing as well as the mgo library (https://labix.org/mgo) to interface with mongo database
The code utilizes the socket pool that comes with the mgo library for efficient concurrent communication with Mongodb. It also makes use of the nice http routing and handling syntax that comes with Gorilla mux.
Like this? check my website for more Go articles: www.minaandrawos.com