
This project is a simple URL shortener service built in Go. It allows users to shorten long URLs and redirect to the original URLs.
url-shortener
├── cmd
│ └── main.go # Main entry point for the application
├── internal
│ ├── handler
│ │ └── handler.go # HTTP handler functions for API endpoints
│ ├── repository
│ │ └── repository.go # Data access layer for interacting with the database
│ ├── service
│ └── service.go # Business logic for processing URL shortening requests
├── pkg
│ └── shortener
│ └── shortener.go # Implementation of the URL shortener logic
├── go.mod # Go module file defining dependencies
└── README.md # Documentation for the project
-
Clone the repository:
git clone <repository-url> cd url-shortener
-
Install dependencies:
go mod tidy
-
Run the application:
go run cmd/main.go
- To shorten a URL, send a POST request to
/shorten
with the original URL in the request body. - To redirect to the original URL, send a GET request to
/{shortened-path}
.
Feel free to submit issues or pull requests for improvements or bug fixes.