Simple URL shortener written in Rust
Request POST on /shorten
with a json body, example: { "url": "__full_url__" }
❯ curl -v -H "Content-Type: application/json" -d '{ "url": "https://github.com/err0rless/rschat/blob/master/src/server/mod.rs" }' localhost:8080/shorten
Request GET on /
with shortened URL
❯ curl -v localhost:8080/Wcrryb7uS
# or access to the URL with your web browser
You're getting 201 Created
for POST and 308 Permanent Redirect
with original location for GET
❯ curl -v -H "Content-Type: application/json" -d '{ "url": "https://github.com/err0rless/rschat/blob/master/src/server/mod.rs" }' localhost:8080/shorten
...
< HTTP/1.1 201 Created
...
{"short_url":"Wcrryb7uS"}
❯ curl -v localhost:8080/Wcrryb7uS
...
>
< HTTP/1.1 308 Permanent Redirect
< location: https://github.com/err0rless/rschat/blob/master/src/server/mod.rs
< content-length: 0
...
You're getting 404 Not Found
❯ curl -v localhost:8080/__NOT_FOUND__
...
>
< HTTP/1.1 404 Not Found
< content-length: 0
...
If system caught unrecognized errors, you're getting 500 Internal Server Error
- Take machine ID for distributed system
- Use our own EPOCH instead of Unix's for even shorter URLs
- Use persistent DB