Git Product home page Git Product logo

url-shortner's Introduction

Screenshot 2024-04-26 at 9 19 48 AM

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.

Clone the repository to your local machine:

git clone https://github.com/Prince-1501/url-shortner.git

Usage

Running the Server

Navigate to the project directory and run the following command to start the server:

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:

curl -X POST http://localhost:8080/shorten -H "Content-Type: application/json" -d '{"url": "https://example.com"}'

The response will contain a JSON object with the shortened URL:

{
    "short_url": "https://www.linkedin.com/in/iamprince/"
}

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:

curl http://localhost:8080/redirect/abcdef

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.

License

This project is licensed under the MIT License - see the LICENSE file for details.

url-shortner's People

Contributors

prince-1501 avatar

Stargazers

SATYAM KUMAR PANDEY avatar  avatar Amit Kumar avatar  avatar Mir Kamrul Ahsan Asif 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.