url-shortener

command module
v0.0.0-...-43c1e5f Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2020 License: MIT Imports: 14 Imported by: 0

README

url-shortener

Go PkgGoDev

A URL shortener written in Go.

Available Ports & Adaptors

Repositories
  • MongoDB
  • Redis
Serializers
  • JSON
  • MessagePack

Development

  1. Start Mongo and Redis servers
    • docker-compose up
    • For Mongo add the redirects collection
    • Mongo Express is accessible at http://localhost:8081
  2. Copy sample.env to .env and update values
    • Set DB_TYPE to mongo or redis
  3. Start the application
    • go run main.go
    • The application is accessible at http://localhost:8080

Endpoints

GET /

A health check endpoint that displays a message if the server is running.

POST /

Creates a new redirect and returns the code.

Body
{
    "url": "http:/example.com"
}
Response
{
  "code": "Rz5x645Mg",
  "url": "https://example.com",
  "created_at": 1602164689
}
GET /{code}

Redirects you to the URL for the specified code.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
repository
serializer

Jump to

Keyboard shortcuts

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