REST/JSON server for managing users and scores.
- Server programming language: go
- Database backend: Redis
- API style: REST and JSON
- Web framework: martini
- Middleware: binding, render and permissions2
- Instant forms: webhandle
- Webserver for http/https, and proxy for server apps: nginx
- Encryption: HTTP over TLS/SSL
- redis and go (the package is often named "golang")
- Use HTTPS whenever using HTTP Basic Auth
- ANY can be GET, POST, PUT or anything
- For an URL like /api/1.0/create/:username/:password, :username should be replaced with the desired username and :password with the desired password, when making the HTTP request.
-
HTTP GET /
- Reveals if an administrator user has been created or not.
-
HTTP ANY /status
- Reveals if an administrator exists and the login status.
-
HTTP GET /admin
- Administration panel. Not implemented yet.
-
HTTP GET /register
- For registrating a new administrator by filling in a form.
-
HTTP POST /register
- For registering a new administrator, needs the form names 'password1', 'password2' and 'email'.
- Username is 'admin' by default.
- Only works if an administrator has not yet been registered.
-
HTTP GET /login
- For logging in the administrator by filling in a form.
-
HTTP POST /login
- For logging in the administrator, needs the form name 'password'.
- Username is 'admin' by default.
-
HTTP ANY /logout
- For logging out the administrator.
The following calls requires authentication with HTTP Basic Auth, where the username is 'admin' and the password is set when creating the admin user with the /register call above.
- HTTP ANY /api/1.0/
- Returns the JSON data: {"all systems": "go"} as a test.
-
HTTP POST /api/1.0/create/:username
- Create a new user, with empty password and email.
-
HTTP POST /api/1.0/register/:username/:password/:email
- Create a new user, with a username, password and email address.
-
HTTP POST /api/1.0/login/:username/:password
- Log in a user, given a username and a password.
-
HTTP ANY /api/1.0/logout/:username
- Log out a user, given a username.
-
HTTP ANY /api/1.0/status/:username
- Show the login status for a given username.
-
HTTP POST /api/1.0/score/:username/:score
- Set a score for a given username.
-
HTTP GET /api/1.0/score/:username
- Return the score for a given username.
-
HTTP POST /api/1.0/fb/reg/:username/:userAccessToken
- Store a facebook user access token for a given user
-
HTTP GET /api/1.0/fb/friends/:username
- Return the number of facebook friends for a given user (must be registered)
-
HTTP POST /api/1.0/insta/reg/:username/:userID/:userAccessToken
- Store a instagram user ID and access token for a given user
-
HTTP GET /api/1.0/insta/friends/:username
- Return the number of instagram friends for a given user (must be registered)
For testing one server state for several clients. Just a test.
-
/circle.html
- Page that displays an expanding circle, if the trigger is set
-
/trigger
- Show the trigger status in a template
-
HTTP GET /trigger/get
- Get the status of the trigger (true or false)
-
HTTP GET /trigger/set
- Set the trigger to true
-
HTTP GET /trigger/clear
- Set the trigger to false
- Administration panel
- For changing the username for the administrator
- For changing the password for the administrator
- For listing and managing registered users
Set the HOST and PORT environment variables for running the server on a different host/port. This is handled by the martini package.
- Version: 0.1
- Author: Alexander F Rødseth, 2015
- License: MIT