Documentation
¶
Overview ¶
Package rest provides link services with a REST API over HTTP.
Package rest provides link management services over HTTP.
Main components ¶
- Shorten - Shortens a URL.
- Resolve - Resolves a shortened URL.
- Health - Checks the health of the service.
Example handler usage ¶
mux := http.NewServeMux()
mux.Handle("POST /shorten", Shorten(...))
mux.Handle("GET /r/{key}", Resolve(...))
mux.HandleFunc("GET /health", Health)
Shorten a URL:
$ curl localhost:8080/shorten -d '{"url":"https://x.com/inancgumus"}'
Resolve a shortened URL:
$ curl localhost:8080/r/639508a7
Health check:
$ curl localhost:8080/health
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Health ¶
func Health(w http.ResponseWriter, r *http.Request)
Health serves the health check requests.
func Resolve ¶
Resolve returns an HTTP handler that resolves shortened link URLs. It extracts a {key} from http.Request using http.Request.PathValue.
Types ¶
Click to show internal directories.
Click to hide internal directories.