Technical Assignment

###Create a REST API service in Go.
The API should consist of two endpoints:

  1. GET /result – Returns status code 200 with a json value that depends on the query:

    • {"result":"ok"} if “status=ok” is present in the query (e.g “/result?status=ok”)
    • {"result":"failure"} of “status=ok” is not present in the query
  2. GET /compute – Simulates compute heavy operation by waiting (sleep) for 100ms to 1000ms (selected randomly) and then redirects users to /result?status=ok

    • If the endpoint takes more than 500ms, it should “timeout” by redirecting the user to /result endpoint without “status=ok”. That means that ~50% of requests are expected to timeout with redirect to “/result” and another 50% result in redirect to “/result?status=ok”.
    • Important: On “timeout” user should be redirect to /result with status 302 Found instead of default timeout with status code 408

Quick start

$ go run cmd/app/main.go

Test App

$ go test ./...

GitHub

View Github