Giter VIP home page Giter VIP logo

kussx's Introduction

kussx

A URL Shortener Service project for recreation/demo purposes.

This project has the following technological stack:

Rest API

POST /shorten

Accepts an application/json payload in the body that shall contain a field named url with the value containing the url that shall be shortened.

Replies with a 200 OK status and a application/json payload with a single field named key with the key that shall be used as a shortcut for the provided url, if everything went OK, otherwise a 500 Internal Server Error is returned.

GET /:key

Replies with either a 404 Not Found if the provided key is not found or with 307 Temporary Redirect with the actual url in the Location header.

DELETE /:key

Deletes the entry associated with the given key. Replies with a 200 OK if everything goes smoothly, otherwise a 500 Internal Server Error is returned.

Try it out

Simply copy the docker-compose.yml file (the image will be pulled from DockerHub) and run docker-compose up. The Rest API shall be available at port 80.

You can also clone the repository, ./gradlew build and use the docker-compose.yml file to target the local Dockerfile instead of the (remote) image.

Examples

Examples rely on the awesome httpie HTTP client.

 $ http http://localhost/test
HTTP/1.1 404 Not Found
Content-Length: 9
Not Found

 $ http post http://localhost/shorten url=https://youtube.com
HTTP/1.1 200 OK
Content-Length: 12
{"key":"Dl"}

 $ http http://localhost/Dl
HTTP/1.1 307 Temporary Redirect
Content-Length: 0
Location: https://youtube.com

 $ http delete http://localhost/Dl
HTTP/1.1 200 OK
Content-Length: 0

kussx's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.