Giter VIP home page Giter VIP logo

rest-service's Introduction

Your Task

Our company has released a beta version of String Reply Service and it has been a huge success. In the current implementation, the String Reply Service takes in an input string (in the format of [a-z0-9]*) and returns the input in a JSON object.

For example,

GET /reply/kbzw9ru
{
    "data": "kbzw9ru"
}

As the service is widely adopted, there have been increasing feature requests. Our project manager has come back with the following requirement:

The input string will now be comprised of two components, a rule and a string, separated by a dash (-). Rules always contain two numbers. Each number represents a string operation.

The supported numbers are:

  • 1: reverse the string

    E.g. kbzw9ru becomes ur9wzbk

  • 2: encode the string via MD5 hash algorithm

    E.g. kbzw9ru becomes 0fafeaae780954464c1b29f765861fad

The numbers are applied in sequence, i.e. the output of the first rule will serve as the input of the second rule. The numbers can also be repeated, i.e. a rule of 11 would mean reversing the string twice, resulting in no change to the string.

Giving a few examples,

GET /v2/reply/11-kbzw9ru
{
    "data": "kbzw9ru"
}
GET /v2/reply/12-kbzw9ru
{
    "data": "5a8973b3b1fafaeaadf10e195c6e1dd4"
}
GET /v2/reply/22-kbzw9ru
{
    "data": "e8501e64cf0a9fa45e3c25aa9e77ffd5"
}

What you need to do

Use the boilerplate given and implement the above requirement. Your implementation should consider future requirements, i.e. be able to easily add new rules.

Upon completing the task, please feel free to (though not required):

  • host your code on Github
  • include any readme to explain your setup/environment
  • add/implement anything you think would be beneficial

Build project

To build the project, simply run

./gradlew build

Start project

To start the project, simply run

./gradlew bootRun

Once the service started, the endpoint will be available at localhost:8080, so you can make request to the service endpoint

GET localhost:8080/reply/helloworld

{
    message: "helloword"
}

rest-service's People

Watchers

James Cloos avatar Ajit Singh 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.