-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a90acf7
commit ca2dc81
Showing
8 changed files
with
240 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Create a .env file with the following variables | ||
REDIS_HOST = "REDIS_HOST" | ||
REDIS_PASSWORD = "REDIS_PASSWORD" | ||
REDIS_DB = REDIS_DB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,97 @@ | ||
# goURLShortnet | ||
Go url shortner | ||
# goURLShortner 🔗 | ||
|
||
A lightning-fast URL shortening service built with Go and Redis, designed for high performance and reliability. | ||
|
||
[](https://github.com/SartajBhuvaji/goURLShortnet/actions/workflows/go.yml) | ||
|
||
[](https://goreportcard.com/report/github.com/SartajBhuvaji/goURLShortnet) | ||
|
||
[](LICENSE) | ||
|
||
## 🚀 Features | ||
|
||
- **Fast URL Shortening**: Efficient Base62 encoding for short, memorable URLs | ||
- **Redis Backend**: High-performance storage and retrieval | ||
- **RESTful API**: Clean and intuitive API endpoints | ||
- **Analytics**: Track creation time, last access, and usage count | ||
- **Concurrent Processing**: Handle multiple requests efficiently | ||
- **Production Ready**: Includes tests, CI/CD, and comprehensive error handling | ||
|
||
## 🛠️ Tech Stack | ||
|
||
- **Go** - Core programming language | ||
- **Redis** - Primary database | ||
- **godotenv** - Environment configuration | ||
- **go-redis** - Redis client for Go | ||
|
||
## 📋 Prerequisites | ||
|
||
- Go 1.23.2 or higher | ||
- Redis server | ||
- Git | ||
|
||
## 🔧 Installation | ||
|
||
1. **Clone the repository** | ||
```bash | ||
git clone https://github.com/YourUsername/goURLShortner.git | ||
cd goURLShortner | ||
``` | ||
|
||
2. **Install dependencies** | ||
```bash | ||
go mod download | ||
``` | ||
|
||
3. **Configure environment** | ||
Create a `.env` file in the root directory: | ||
```env | ||
REDIS_HOST=localhost:6379 | ||
REDIS_PASSWORD=your_redis_password | ||
REDIS_DB=0 | ||
``` | ||
|
||
## 🚦 Usage | ||
|
||
1. **Start the server** | ||
```bash | ||
go run main.go | ||
``` | ||
Server starts on `http://localhost:8080` | ||
|
||
2. **API Endpoints** | ||
|
||
### Shorten URL | ||
```http | ||
POST /shorten | ||
Content-Type: application/json | ||
{ | ||
"url": "https://www.example.com/very/long/url/that/needs/shortening" | ||
} | ||
``` | ||
Response: | ||
```json | ||
{ | ||
"short_url": "www.goURLShortner/abc123" | ||
} | ||
``` | ||
|
||
### Redirect to Original URL | ||
```http | ||
GET /redirect?url=abc123 | ||
``` | ||
Response: | ||
```json | ||
{ | ||
"long_url": "https://www.example.com/very/long/url/that/needs/shortening" | ||
} | ||
``` | ||
|
||
## 🧪 Testing | ||
|
||
Run the test suite: | ||
|
||
```bash | ||
go test ./tests -v | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,3 +32,5 @@ func main() { | |
log.Fatalf("Could not start server: %s\n", err) | ||
} | ||
} | ||
|
||
// RUN: go run main.go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.