Skip to content

callumyuille/testing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

urlshort

A minimal URL shortener service written in Go. Stores mappings in memory and exposes a small JSON/HTTP API.

Requirements

  • Go 1.22+

Running

make run
# or
go run ./cmd/server

The server listens on :8080 by default; override with the ADDR environment variable.

API

Method Path Description
POST /shorten Shorten a URL. Body: {"url": "https://…"}
GET /{code} Redirect to the original URL
GET /healthz Health check

Example:

curl -s -X POST localhost:8080/shorten -d '{"url":"https://example.com"}'
# {"code":"aB3xY9z"}

curl -i localhost:8080/aB3xY9z
# HTTP/1.1 302 Found

Development

make test   # run tests
make lint   # go vet
make build  # build binary into bin/

Project layout

  • cmd/server — application entrypoint
  • internal/shortener — HTTP handlers and shortening logic
  • internal/storage — storage interface and in-memory implementation

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors