Skip to content
/ shortNgo Public

A simple url shortener powered by Go and HTMX

License

Notifications You must be signed in to change notification settings

pvskp/shortNgo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ShortNGo

ShortNGo is a URL shortening service built with Go and powered by HTMX. It uses BadgerDB as the underlying storage mechanism to store and retrieve shortened URLs.

Features

  • Shorten long URLs.
  • Redirect to the original URL using the shortened URL.
  • Uses a hash function to generate unique shortened URLs.
  • In-memory database using BadgerDB for fast performance.

Prerequisites

  • Go 1.16 or higher
  • Internet connection to fetch dependencies

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/shortngo.git
cd shortngo
  1. Install dependencies:
go mod tidy

Usage

  1. Run the application:
go run .
  1. Open your web browser and go to http://localhost:8080.

Endpoints

  • POST /process

    This endpoint accepts a URL via a form and generates a shortened version.

  • GET /go/{hash}

    This endpoint redirects to the original URL associated with the given hash.

    Example:

    curl http://localhost:8080/go/c19fcdc5

Project Structure

  • main.go - Entry point of the application, handles HTTP routing and request processing.
  • database/* - Contains the database implementations and factory.

Testing

To run the tests, use the following command:

go test ./...

This will execute the tests defined in database/badgerim_test.go to ensure the database implementation is working as expected.

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Acknowledgements

  • BadgerDB for the in-memory database.
  • HTMX for handling AJAX requests in a simpler way.
  • Murmur3 for the hashing function.

Feel free to customize this README to better fit your project and personal style.

About

A simple url shortener powered by Go and HTMX

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published