Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pantrif/url-shortener
A golang URL Shortener
https://github.com/pantrif/url-shortener
bijective golang url-shortener
Last synced: 14 days ago
JSON representation
A golang URL Shortener
- Host: GitHub
- URL: https://github.com/pantrif/url-shortener
- Owner: pantrif
- License: mit
- Created: 2018-06-04T05:57:45.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-02-06T10:28:56.000Z (almost 2 years ago)
- Last Synced: 2024-07-31T20:52:32.606Z (3 months ago)
- Topics: bijective, golang, url-shortener
- Language: Go
- Size: 24.4 KB
- Stars: 48
- Watchers: 2
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-go - url-shortener - A modern, powerful, and robust URL shortener microservice with mysql support. (Miscellaneous / Uncategorized)
- zero-alloc-awesome-go - url-shortener - A modern, powerful, and robust URL shortener microservice with mysql support. (Miscellaneous / Uncategorized)
- awesome-go - url-shortener - A golang URL Shortener - ★ 9 (Miscellaneous)
- awesome-go-extra - url-shortener - 06-04T05:57:45Z|2018-06-09T14:39:44Z| (Microsoft Office / Uncategorized)
- awesome-go-zh - url-shortener
README
[![Build Status](https://travis-ci.com/pantrif/url-shortener.svg?branch=master)](https://travis-ci.com/pantrif/url-shortener)
[![Go Report Card](https://goreportcard.com/badge/github.com/pantrif/url-shortener)](https://goreportcard.com/report/github.com/pantrif/url-shortener)
[![GoDoc](https://godoc.org/github.com/pantrif/url-shortener?status.png)](http://godoc.org/github.com/pantrif/url-shortener)# url-shortener
A golang URL Shortener with mysql support.
Using Bijective conversion between natural numbers (IDs) and short strings# Installation
## Using docker compose
```
docker-compose up --build
```
## Using an existing mysqlEdit .env file to add connection strings for mysql
Run mysql_init/create_table.sql
```
go run main.go
```# Usage
## Create short url
```
curl -X POST -H "Content-Type:application/json" -d "{\"url\": \"http://www.google.com\"}" http://localhost:8081/shorten
```
Expected output
```
{"url":"localhost:8081/3"}
```## Redirect
```
curl -v localhost:8081/3
```
Output
```
* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8081 (#0)
> GET /3 HTTP/1.1
> Host: localhost:8081
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 303 See Other
< Location: http://www.google.com
< Date: Mon, 04 Jun 2018 08:03:13 GMT
< Content-Length: 48
< Content-Type: text/html; charset=utf-8
<
See Other.
```# Licence
This module is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)