You are tasked with creating an API for a poll system. The API should allow users to create and interact with polls, while also ensuring that administrative controls are in place to manage and view all polls. The API will implement basic authentication, allowing actions to be restricted based on user roles. You will be using the Clojure programming language and the Reitit library for routing.
The API will use hardcoded authentication with API keys for now. Just assume the Authorisation:
header will have one of the following API keys:
(def auth-keys
{:admin {:api-key "123adminkey"}
:user1 {:api-key "123user1"}
:user2 {:api-key "123user2"}})
A poll will have at least the following data which you will receive via POST. You can assume this comes in EDN format.
poll-id
: A unique identifier for the poll.question
: The question being asked in the poll.options
: A list of possible options for users to vote on.The structure is purposefully vague, we’d like your input into how a good poll design may look. Please consider this data structure carefully and extend it as you see fit given the task at hand.
We would like the system to be able to notify listeners of changes to a poll - please account for something in your submission to make this possible. Long polling or websockets are a couple of ways you might achieve this.
Authorization
header using API keys.