go-urlshortner

command module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2023 License: BSD-3-Clause Imports: 9 Imported by: 0

README

Go URL Shortener

Go Report Card

This is a simple URL shortening service written in Go, which utilizes the Gin Web Framework for routing and Google Cloud Datastore for persistent storage.

Introduction

Go Picture

This project aims to provide a straightforward and scalable approach to creating short aliases for lengthy URLs. It's constructed in Go and is designed to be simple to deploy and maintain. The service includes basic functionalities such as generating a shortened URL and redirecting to the original URL when accessed.

Features

  • Shorten URLs: Convert long URLs into short, manageable links that are easier to share.
  • Redirection: Use the generated short link to redirect to the original URL.
  • Simple Integration: Easily integrate with your applications using RESTful API endpoints.

Getting Started

To use the Go URL Shortener, you'll need to make HTTP requests to its API endpoints. Currently, the service supports creating short URLs with a POST request.

Example Creating a Short URL

To create a short URL, send a POST request with a JSON payload containing the original URL. You'll also need to include a custom internal secret header for authentication purposes.

$ curl -X POST \
  https://example-your-deployurl-go-dev.a.run.app/ \
  -H 'Content-Type: application/json' \
  -H 'X-Internal-Secret: YOURKEY-SECRET' \
  -d '{"url": "https://go.dev/"}'

Replace YOURKEY-SECRET with the actual secret key required by your deployment.

The service will respond with a JSON object that includes the ID of the shortened URL:

{
  "id": "{ShortenedID}",
  "shortened_url": "https://example-your-deployurl-go-dev.a.run.app/{ShortenedID}"
}

You can then access the shortened URL at https://example-your-deployurl-go-dev.a.run.app/{ShortenedID}, which will redirect you to the original URL.

Contributing

Contributions are welcome! For major changes, please open an issue first to discuss what you would like to change.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL