Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

URL SHORTENER

Easily convert a long URL into short URL.

Features

  • create a short URL from a long URL
  • redirect from a short URL to the original URL
  • in-memory storage
  • basic collision handling
  • concurrent access protection with a mutex
  • minimal home page

How it works

  • the client sends a long URL to POST /shorten
  • a unique short identifier is generated
  • the mapping between the short URL and the long URL is stored in memory
  • when GET /<id> is called, the client is redirected to the original URL
  • GET / serves a minimal home page

Run locally

By default, the server runs on: http://localhost:8081
You can configure the base URL with the SITEURL environment variable

export SITEURL=your_own_site_with_http

clone the repository, then start the server:

go run main.go

In another terminal window, create a short URL from a long one

curl -X  POST -d "url=http://example.com/some_very_long_url" http://localhost:8081/shorten

Response

http://localhost:8081/short_url

Limitations

  • in-memory storage only
  • data is lost when the server stops

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages