https://github.com/suraj-encoding/shortify
🕸️ URL Shortener Using Golang 🕸️
https://github.com/suraj-encoding/shortify
aws docker ec2 go linux render server-on-cloud shortify url-shortener vm
Last synced: 6 months ago
JSON representation
🕸️ URL Shortener Using Golang 🕸️
- Host: GitHub
- URL: https://github.com/suraj-encoding/shortify
- Owner: Suraj-Encoding
- Created: 2024-08-27T14:03:27.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-10-24T09:43:38.000Z (over 1 year ago)
- Last Synced: 2025-02-07T16:45:15.797Z (12 months ago)
- Topics: aws, docker, ec2, go, linux, render, server-on-cloud, shortify, url-shortener, vm
- Language: Go
- Homepage: https://shortwave.onrender.com
- Size: 27.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# URL Shortener
A simple URL shortening service built in Go
## Overview
This project provides a basic URL-shortening service implemented in Go. It allows users to shorten long URLs into more manageable and shareable links. The service also includes a redirect feature to redirect users from the shortened URL to the original long URL.
## Installation
To use the URL shortener, you need to have Go installed on your system. You can download and install Go from the [official Go website](https://go.dev/).
Clone the repository to your local machine:
```sh
git clone https://github.com/Suraj-Encoding/Shortify.git
```
## Usage
### Running the Server
Navigate to the project directory and run the following command to start the server:
```sh
go run main.go
```
The server will start listening on port `8080` by default. You can change the port in the `main.go` file if needed.
### Shortening a URL
To shorten a URL, send a POST request to the `/shorten` endpoint with a JSON payload containing the original URL:
```sh
curl -X POST http://localhost:8080/shorten -H "Content-Type: application/json" -d '{"url": "https://www.linkedin.com/username"}'
```
The response will contain a JSON object with the shortened URL:
```json
{
"short_url": "http://localhost:8080/redirect/a2352b"
}
```
### Redirecting to the Original URL
To redirect to the original URL, visit the shortened URL in your browser or send a GET request to the `/redirect/{id}` endpoint, where `{id}` is the shortened URL ID:
```sh
curl http://localhost:8080/redirect/a2352b
```
This will redirect you to the original URL associated with the shortened URL.
## Contributing
Contributions are welcome! Feel free to fork the repository and submit pull requests.